-
public class Connection extends EventEmitter<ConnectionEvent, ConnectionStateListener>
Enables the management of a connection to Ably. Extends an EventEmitter object.
Spec: RTN4a, RTN4e, RTN4g
-
-
Field Summary
Fields Modifier and Type Field Description public ConnectionStatestatepublic ErrorInforeasonpublic Stringkeypublic StringrecoveryKeypublic Stringidpublic final ConnectionManagerconnectionManager
-
Method Summary
Modifier and Type Method Description StringcreateRecoveryKey()createRecoveryKey is a method that returns a json string which incorporates the @connectionKey@, thecurrent @msgSerial@, and a collection of pairs of channel @name@ and current @channelSerial@ for everycurrently attached channel. voidconnect()Explicitly calling connect() is unnecessary unless the autoConnect attribute of the io.ably.lib.types.ClientOptions object is false. voidping(CompletionListener listener)When connected, sends a heartbeat ping to the Ably server and executes the callback with any error and the responsetime 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. voidclose()Causes the connection to close, entering the closing state. voidonConnectionStateChange(ConnectionStateListener.ConnectionStateChange stateChange)voidemitUpdate(ErrorInfo errorInfo)voidemit(ConnectionState state, ConnectionStateListener.ConnectionStateChange stateChange)voidon(ConnectionState state, ConnectionStateListener listener)voidonce(ConnectionState state, ConnectionStateListener listener)-
-
Method Detail
-
createRecoveryKey
String createRecoveryKey()
createRecoveryKey is a method that returns a json string which incorporates the @connectionKey@, thecurrent @msgSerial@, and a collection of pairs of channel @name@ and current @channelSerial@ for everycurrently attached channel.
Spec: RTN16g, RTN16c
-
connect
void connect()
Explicitly calling connect() is unnecessary unless the autoConnect attribute of the io.ably.lib.types.ClientOptions object is false.Unless already connected or connecting, this method causes the connection to open,entering the connecting state.
Spec: RTC1b, RTN3, RTN11
-
ping
void ping(CompletionListener listener)
When connected, sends a heartbeat ping to the Ably server and executes the callback with any error and the responsetime 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.
- Parameters:
listener- A listener to be notified of success or failure.
-
close
void close()
Causes the connection to close, entering the closing state.Once closed, the library does not attempt to re-establish the connection without an explicit call to connect.
Spec: RTN12
-
onConnectionStateChange
void onConnectionStateChange(ConnectionStateListener.ConnectionStateChange stateChange)
-
emitUpdate
void emitUpdate(ErrorInfo errorInfo)
-
emit
@Deprecated() void emit(ConnectionState state, ConnectionStateListener.ConnectionStateChange stateChange)
-
on
@Deprecated() void on(ConnectionState state, ConnectionStateListener listener)
-
once
@Deprecated() void once(ConnectionState state, ConnectionStateListener listener)
-
-
-
-