An ErrorInfo object describing the last error received if a connection failure occurs.
Optional
id
A unique public identifier for this connection, used to identify this member.
Optional
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.
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.
The serial number of the last message to be received on this connection, used automatically by the library when recovering or resuming a connection. 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.
Readonly
state
The current ConnectionState of the connection.
Explicitly calling connect()
is unnecessary unless the autoConnect
attribute of the ClientOptions object is false
. Unless already connected or connecting, this method causes the connection to open, entering the CONNECTING state.
Returns the listeners for a specified EventType
.
Optional
eventName: ConnectionEvent
The event name to retrieve the listeners for.
Removes all registrations that match both the specified listener and the specified event.
The named event.
The event listener.
Deregisters the specified listener. Removes all registrations matching the given listener, regardless of whether they are associated with an event or not.
The event listener.
Deregisters all registrations, for all events and listeners.
Registers the provided listener for the specified event. If on()
is called more than once with the same listener and event, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using on()
, and an event is emitted once, the listener would be invoked twice.
The named event to listen for.
The event listener.
Registers the provided listener for the specified events. If on()
is called more than once with the same listener and event, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using on()
, and an event is emitted once, the listener would be invoked twice.
The named events to listen for.
The event listener.
Registers the provided listener all events. If on()
is called more than once with the same listener and event, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using on()
, and an event is emitted once, the listener would be invoked twice.
The event listener.
Registers the provided listener for the first occurrence of a single named event specified as the Event
argument. If once
is called more than once with the same listener, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using once
, and an event is emitted once, the listener would be invoked twice. However, all subsequent events emitted would not invoke the listener as once
ensures that each registration is only invoked once.
The named event to listen for.
The event listener.
Registers the provided listener for the first event that is emitted. If once()
is called more than once with the same listener, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using once()
, and an event is emitted once, the listener would be invoked twice. However, all subsequent events emitted would not invoke the listener as once()
ensures that each registration is only invoked once.
The event listener.
Returns a promise which resolves upon the first occurrence of a single named event specified as the Event
argument.
A promise which resolves upon the first occurrence of the named event.
The named event to listen for.
Returns a promise which resolves upon the first occurrence of an event.
A promise which resolves upon the first occurrence of an event.
When connected, sends a heartbeat ping to the Ably server and executes the callback with any error and the response time in milliseconds when a heartbeat ping request is echoed from the server. This can be useful for measuring true round-trip latency to the connected Ably server.
A promise which, upon success, will be fulfilled with the response time in milliseconds. Upon failure, the promise will be rejected with an ErrorInfo object which explains the error.
Returns a promise which is resolved when the connection reaches the specified ConnectionState. If the connection is already in the specified state, the promise is resolved immediately.
The state which should be reached.
Generated using TypeDoc
Enables the management of a connection to Ably.