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
FieldsModifier and TypeFieldDescriptionfinal ConnectionManagerA 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.AnErrorInfoobject describing the last error received if a connection failure occurs.Deprecated.use createRecoveryKey method instead.The currentConnectionStateof the connection. - 
Method Summary
Modifier and TypeMethodDescriptionprotected voidapply(ConnectionStateListener listener, ConnectionEvent event, Object... args) voidclose()Causes the connection to close, entering theConnectionState.closingstate.voidconnect()Explicitly calling connect() is unnecessary unless the autoConnect attribute of theClientOptionsobject 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.voidemit(ConnectionState state, ConnectionStateListener.ConnectionStateChange stateChange) Deprecated.voidemitUpdate(ErrorInfo errorInfo) voidon(ConnectionState state, ConnectionStateListener listener) Deprecated.voidonce(ConnectionState state, ConnectionStateListener listener) Deprecated.voidvoidping(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 currentConnectionStateof the connection.Spec: RTN4d
 - 
reason
AnErrorInfoobject 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 theClientOptionsobject is false. Unless already connected or connecting, this method causes the connection to open, entering theConnectionState.connectingstate.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.closingstate. Once closed, the library does not attempt to re-establish the connection without an explicit call toconnect().Spec: RTN12
 - 
onConnectionStateChange
 - 
apply
- Specified by:
 - 
applyin classEventEmitter<ConnectionEvent,ConnectionStateListener>  
 - 
emitUpdate
 - 
emit
@Deprecated public void emit(ConnectionState state, ConnectionStateListener.ConnectionStateChange stateChange) Deprecated. - 
on
Deprecated. - 
once
Deprecated. 
 -