Package io.ably.lib.realtime
Class Connection
- java.lang.Object
-
- io.ably.lib.util.EventEmitter<ConnectionEvent,ConnectionStateListener>
-
- io.ably.lib.realtime.Connection
-
public class Connection extends EventEmitter<ConnectionEvent,ConnectionStateListener>
A class representing the connection associated with an AblyRealtime instance. The Connection object exposes the lifecycle and parameters of the realtime connection.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.ably.lib.util.EventEmitter
EventEmitter.Filter
-
-
Field Summary
Fields Modifier and Type Field Description ConnectionManagerconnectionManagerjava.lang.StringidA public identifier for this connection, used to identify this member in presence events and message ids.java.lang.StringkeyThe assigned connection key.ErrorInforeasonError information associated with a connection failure.java.lang.StringrecoveryKeyRTN16b) Connection#recoveryKey is an attribute composed of the connection key and latest serial received on the connectionlongserialThe serial number of the last message to be received on this connection.ConnectionStatestateThe current state of this Connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidapply(ConnectionStateListener listener, ConnectionEvent event, java.lang.Object... args)voidclose()Causes the connection to close, entering the closed state, from any state except the failed state.voidconnect()Causes the library to re-attempt connection, if it was previously explicitly closed by the user, or was closed as a result of an unrecoverable error.voidemit(ConnectionState state, ConnectionStateListener.ConnectionStateChange stateChange)Deprecated.voidemitUpdate(ErrorInfo errorInfo)voidon(ConnectionState state, ConnectionStateListener listener)Deprecated.voidonce(ConnectionState state, ConnectionStateListener listener)Deprecated.voidonConnectionStateChange(ConnectionStateListener.ConnectionStateChange stateChange)voidping(CompletionListener listener)Send a heartbeat message to the Ably service and await a response.
-
-
-
Field Detail
-
state
public ConnectionState state
The current state of this Connection.
-
reason
public ErrorInfo reason
Error information associated with a connection failure.
-
key
public java.lang.String key
The assigned connection key.
-
recoveryKey
public java.lang.String recoveryKey
RTN16b) Connection#recoveryKey is an attribute composed of the connection key and latest serial received on the connection
-
id
public java.lang.String id
A public identifier for this connection, used to identify this member in presence events and message ids.
-
serial
public long serial
The serial number of the last message to be received on this connection.
-
connectionManager
public final ConnectionManager connectionManager
-
-
Method Detail
-
connect
public void connect()
Causes the library to re-attempt connection, if it was previously explicitly closed by the user, or was closed as a result of an unrecoverable error.
-
ping
public void ping(CompletionListener listener)
Send a heartbeat message to the Ably service and await a response.- Parameters:
listener- : a listener to be notified of the outcome of this message.
-
close
public void close()
Causes the connection to close, entering the closed state, from any state except the failed state. Once closed, the library will not attempt to re-establish the connection without a call toconnect().
-
onConnectionStateChange
public void onConnectionStateChange(ConnectionStateListener.ConnectionStateChange stateChange)
-
apply
protected void apply(ConnectionStateListener listener, ConnectionEvent event, java.lang.Object... args)
- Specified by:
applyin classEventEmitter<ConnectionEvent,ConnectionStateListener>
-
emitUpdate
public void emitUpdate(ErrorInfo errorInfo)
-
emit
@Deprecated public void emit(ConnectionState state, ConnectionStateListener.ConnectionStateChange stateChange)
Deprecated.
-
on
@Deprecated public void on(ConnectionState state, ConnectionStateListener listener)
Deprecated.
-
once
@Deprecated public void once(ConnectionState state, ConnectionStateListener listener)
Deprecated.
-
-