public class Connection extends EventEmitter<ConnectionEvent,ConnectionStateListener>
EventEmitter object.
Spec: RTN4a, RTN4e, RTN4g
EventEmitter.Filter| Modifier and Type | Field and Description |
|---|---|
ConnectionManager |
connectionManager |
java.lang.String |
id
A unique public identifier for this connection, used to identify this member.
|
java.lang.String |
key
A unique private connection key used to recover or resume a connection, assigned by Ably.
|
ErrorInfo |
reason
An
ErrorInfo object describing the last error received if a connection failure occurs. |
java.lang.String |
recoveryKey
The recovery key string can be used by another client to recover this connection's state in the recover client options property.
|
long |
serial
The serial number of the last message to be received on this connection,
used automatically by the library when recovering or resuming a connection.
|
ConnectionState |
state
The current
ConnectionState of the connection. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
apply(ConnectionStateListener listener,
ConnectionEvent event,
java.lang.Object... args) |
void |
close()
Causes the connection to close, entering the
ConnectionState.closing state. |
void |
connect()
Explicitly calling connect() is unnecessary unless the autoConnect attribute of the
ClientOptions
object is false. |
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 |
onConnectionStateChange(ConnectionStateListener.ConnectionStateChange stateChange) |
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.
|
public ConnectionState state
ConnectionState of the connection.
Spec: RTN4d
public ErrorInfo reason
ErrorInfo object describing the last error received if a connection failure occurs.
Spec: RTN14a
public java.lang.String key
Spec: RTN9
public java.lang.String recoveryKey
Spec: RTN16b, RTN16c
public java.lang.String id
Spec: RTN8
public long serial
Spec: RTN10
public final ConnectionManager connectionManager
public void connect()
ClientOptions
object is false.
Unless already connected or connecting, this method causes the connection to open,
entering the ConnectionState.connecting state.
Spec: RTC1b, RTN3, RTN11
public void ping(CompletionListener listener)
listener - A listener to be notified of success or failure.
Spec: RTN13
public void close()
ConnectionState.closing state.
Once closed, the library does not attempt to re-establish the connection without an explicit call to connect().
Spec: RTN12
public void onConnectionStateChange(ConnectionStateListener.ConnectionStateChange stateChange)
protected void apply(ConnectionStateListener listener, ConnectionEvent event, java.lang.Object... args)
apply in class EventEmitter<ConnectionEvent,ConnectionStateListener>public void emitUpdate(ErrorInfo errorInfo)
@Deprecated public void emit(ConnectionState state, ConnectionStateListener.ConnectionStateChange stateChange)
@Deprecated public void on(ConnectionState state, ConnectionStateListener listener)
@Deprecated public void once(ConnectionState state, ConnectionStateListener listener)