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. 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. (If you want to explicitly recover a connection in a different SDK instance, see createRecoveryKey() instead)
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.
createRecoveryKey method returns a string that 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.
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.
The named event to listen for.
A promise which resolves upon the first occurrence of the named event.
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.
If the connection is already in the given state, returns a promise which immediately resolves to null
. Else, calls once()
to return a promise which resolves the next time the connection transitions to the given state.
The connection state to wait for.
Generated using TypeDoc
Enables the management of a connection to Ably.