PNHeartbeat Class Reference

Inherits from NSObject
Declared in PNHeartbeat.h

Overview

Allow to notify service and tell what subscriber still alive and waiting for events from live feed.

@author Sergey Mamontov

Initialization and Configuration

+ heartbeatForClient:

Construct and configure heartbeat manager.

+ (instancetype)heartbeatForClient:(PubNub *)client

Parameters

client

Reference on \b PubNub client for which heartbeat manager has been created.

Return Value

Constructed and ready to use heartbeat manager.

Availability

4.0

Declared In

PNHeartbeat.h

State manipulation

– startHeartbeatIfRequired

If client configured with heartbeat value and interval client will send “heartbeat” notification to \b PubNub service.

- (void)startHeartbeatIfRequired

Availability

4.0

Declared In

PNHeartbeat.h

– stopHeartbeatIfPossible

In case if there is active heartbeat timer it will be stopped.

- (void)stopHeartbeatIfPossible

Availability

4.0

Declared In

PNHeartbeat.h

Extension Methods

  client

Stores weak reference on client for which heartbeat manager has been created.

@property (nonatomic, weak) PubNub *client

Availability

4.0

Declared In

PNHeartbeat.m

  heartbeatTimer

Stores reference on timer used to trigger heartbeat requests.

@property (nonatomic, strong) dispatch_source_t heartbeatTimer

Availability

4.0

Declared In

PNHeartbeat.m

  resourceAccessQueue

Stores reference on queue which is used to serialize access to shared heartbeat information.

@property (nonatomic, strong) dispatch_queue_t resourceAccessQueue

Availability

4.0

Declared In

PNHeartbeat.m

– initForClient:

Initialize and configure heartbeat manager.

- (instancetype)initForClient:(PubNub *)client

Parameters

client

Reference on \b PubNub client for which heartbeat manager has been created.

Return Value

Initialized and ready to use heartbeat manager.

Availability

4.0

Declared In

PNHeartbeat.m

– handleHeartbeatTimer

Process heartbeat timer fire event and send heartbeat request to \b PubNub service.

- (void)handleHeartbeatTimer

Availability

4.0

Declared In

PNHeartbeat.m