Package io.ably.lib.realtime
Class Connection
java.lang.Object
io.ably.lib.util.EventEmitter<ConnectionEvent,ConnectionStateListener>
io.ably.lib.realtime.Connection
Enables the management of a connection to Ably.
Extends an
EventEmitter
object.
Spec: RTN4a, RTN4e, RTN4g
-
Nested Class Summary
Nested classes/interfaces inherited from class io.ably.lib.util.EventEmitter
EventEmitter.Filter
-
Field Summary
Modifier and TypeFieldDescriptionfinal ConnectionManager
A unique public identifier for this connection, used to identify this member.A unique private connection key used to recover or resume a connection, assigned by Ably.AnErrorInfo
object describing the last error received if a connection failure occurs.Deprecated.use createRecoveryKey method instead.The currentConnectionState
of the connection. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
apply
(ConnectionStateListener listener, ConnectionEvent event, Object... args) void
close()
Causes the connection to close, entering theConnectionState.closing
state.void
connect()
Explicitly calling connect() is unnecessary unless the autoConnect attribute of theClientOptions
object is false.createRecoveryKey is a method that returns a json string which incorporates the @connectionKey@, the current @msgSerial@, and a collection of pairs of channel @name@ and current @channelSerial@ for every currently attached channel.void
emit
(ConnectionState state, ConnectionStateListener.ConnectionStateChange stateChange) Deprecated.void
emitUpdate
(ErrorInfo errorInfo) void
on
(ConnectionState state, ConnectionStateListener listener) Deprecated.void
once
(ConnectionState state, ConnectionStateListener listener) Deprecated.void
void
ping
(CompletionListener listener) 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.
-
Field Details
-
state
The currentConnectionState
of the connection.Spec: RTN4d
-
reason
AnErrorInfo
object describing the last error received if a connection failure occurs.Spec: RTN14a
-
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.Spec: RTN9
-
recoveryKey
Deprecated.use createRecoveryKey method instead.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.Spec: RTN16m
-
id
A unique public identifier for this connection, used to identify this member.Spec: RTN8
-
connectionManager
-
-
Method Details
-
createRecoveryKey
createRecoveryKey is a method that returns a json string which incorporates the @connectionKey@, the current @msgSerial@, and a collection of pairs of channel @name@ and current @channelSerial@ for every currently attached channel.Spec: RTN16g, RTN16c
-
connect
public void connect()Explicitly calling connect() is unnecessary unless the autoConnect attribute of theClientOptions
object is false. Unless already connected or connecting, this method causes the connection to open, entering theConnectionState.connecting
state.Spec: RTC1b, RTN3, RTN11
-
ping
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.- Parameters:
-
listener
- A listener to be notified of success or failure.Spec: RTN13
-
close
public void close()Causes the connection to close, entering theConnectionState.closing
state. Once closed, the library does not attempt to re-establish the connection without an explicit call toconnect()
.Spec: RTN12
-
onConnectionStateChange
-
apply
- Specified by:
-
apply
in classEventEmitter<ConnectionEvent,
ConnectionStateListener>
-
emitUpdate
-
emit
@Deprecated public void emit(ConnectionState state, ConnectionStateListener.ConnectionStateChange stateChange) Deprecated. -
on
Deprecated. -
once
Deprecated.
-