ARTConnectionProtocol

Objective-C

@protocol ARTConnectionProtocol <NSObject>

Swift

protocol ARTConnectionProtocol : NSObjectProtocol

The protocol upon which the ARTConnection is implemented. Also embeds ARTEventEmitter.

  • id

    A unique public identifier for this connection, used to identify this member.

    Declaration

    Objective-C

    @property (readonly, nullable) NSString *id;

    Swift

    var id: String? { get }
  • key

    A unique private connection key used to recover or resume a connection, assigned by Ably. When recovering a connection explicitly, the recoveryKey is used in the recover client options as it contains both the key and the last message serial. This private connection key can also be used by other REST clients to publish on behalf of this client. See the publishing over REST on behalf of a realtime client docs for more info.

    Declaration

    Objective-C

    @property (readonly, nullable) NSString *key;

    Swift

    var key: String? { get }
  • The maximum message size is an attribute of an Ably account and enforced by Ably servers. maxMessageSize indicates the maximum message size allowed by the Ably account this connection is using. Overrides the default value of +[ARTDefault maxMessageSize].

    Declaration

    Objective-C

    @property (readonly) NSInteger maxMessageSize;

    Swift

    var maxMessageSize: Int { get }
  • The current ARTRealtimeConnectionState of the connection.

    Declaration

    Objective-C

    @property (readonly) ARTRealtimeConnectionState state;

    Swift

    var state: ARTRealtimeConnectionState { get }
  • An ARTErrorInfo object describing the last error received if a connection failure occurs.

    Declaration

    Objective-C

    @property (readonly, nullable) ARTErrorInfo *errorReason;

    Swift

    var errorReason: ARTErrorInfo? { get }
  • Deprecated

    Use createRecoveryKey method instead.

    This property is deprecated and will be removed in future versions of the library. You should use createRecoveryKey method instead.

    Declaration

    Objective-C

    @property (readonly, nullable) NSString *recoveryKey;

    Swift

    var recoveryKey: String? { get }
  • The recovery key string can be used by another client to recover this connection’s state in the recover client options property. See connection state recover options for more information. This will return nil if connection is in CLOSED, CLOSING, FAILED, or SUSPENDED states, or when it does not have a connection key (for example, it has not yet become connected).

    Declaration

    Objective-C

    - (nullable NSString *)createRecoveryKey;

    Swift

    func createRecoveryKey() -> String?
  • Explicitly calling connect is unnecessary unless the ARTClientOptions.autoConnect is false. Unless already connected or connecting, this method causes the connection to open, entering the ARTRealtimeConnectionState.ARTRealtimeConnecting state.

    Declaration

    Objective-C

    - (void)connect;

    Swift

    func connect()
  • Causes the connection to close, entering the ARTRealtimeConnectionState.ARTRealtimeClosing state. Once closed, the library does not attempt to re-establish the connection without an explicit call to -[ARTConnectionProtocol connect].

    Declaration

    Objective-C

    - (void)close;

    Swift

    func close()
  • When connected, sends a heartbeat ping to the Ably server and executes the callback with an error if any. This can be useful for measuring true round-trip latency to the connected Ably server.

    Declaration

    Objective-C

    - (void)ping:(nonnull ARTCallback)callback;

    Swift

    func ping(_ callback: @escaping ARTCallback)

    Parameters

    callback

    A success or failure callback function.

ARTEventEmitter