Package io.ably.lib.realtime
Enum ConnectionState
- java.lang.Object
-
- java.lang.Enum<ConnectionState>
-
- io.ably.lib.realtime.ConnectionState
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<ConnectionState>
public enum ConnectionState extends java.lang.Enum<ConnectionState>
Describes the realtimeConnectionobject states.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description closedThe connection has been explicitly closed by the client.closingAn explicit request by the developer to close the connection has been sent to the Ably service.connectedA connection exists and is active.connectingA connection attempt has been initiated.disconnectedA temporary failure condition.failedThis state is entered if the client library encounters a failure condition that it cannot recover from.initializedA connection with this state has been initialized but no connection has yet been attempted.suspendedA long term failure condition.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectionEventgetConnectionEvent()static ConnectionStatevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static ConnectionState[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
initialized
public static final ConnectionState initialized
A connection with this state has been initialized but no connection has yet been attempted.
-
connecting
public static final ConnectionState connecting
A connection attempt has been initiated. The connecting state is entered as soon as the library has completed initialization, and is reentered each time connection is re-attempted following disconnection.
-
connected
public static final ConnectionState connected
A connection exists and is active.
-
disconnected
public static final ConnectionState disconnected
A temporary failure condition. No current connection exists because there is no network connectivity or no host is available. The disconnected state is entered if an established connection is dropped, or if a connection attempt was unsuccessful. In the disconnected state the library will periodically attempt to open a new connection (approximately every 15 seconds), anticipating that the connection will be re-established soon and thus connection and channel continuity will be possible. In this state, developers can continue to publish messages as they are automatically placed in a local queue, to be sent as soon as a connection is reestablished. Messages published by other clients while this client is disconnected will be delivered to it upon reconnection, so long as the connection was resumed within 2 minutes. After 2 minutes have elapsed, recovery is no longer possible and the connection will move to the SUSPENDED state.
-
suspended
public static final ConnectionState suspended
A long term failure condition. No current connection exists because there is no network connectivity or no host is available. The suspended state is entered after a failed connection attempt if there has then been no connection for a period of two minutes. In the suspended state, the library will periodically attempt to open a new connection every 30 seconds. Developers are unable to publish messages in this state. A new connection attempt can also be triggered by an explicit call toConnection.connect(). Once the connection has been re-established, channels will be automatically re-attached. The client has been disconnected for too long for them to resume from where they left off, so if it wants to catch up on messages published by other clients while it was disconnected, it needs to use the History API.
-
closing
public static final ConnectionState closing
An explicit request by the developer to close the connection has been sent to the Ably service. If a reply is not received from Ably within a short period of time, the connection is forcibly terminated and the connection state becomes CLOSED.
-
closed
public static final ConnectionState closed
The connection has been explicitly closed by the client. In the closed state, no reconnection attempts are made automatically by the library, and clients may not publish messages. No connection state is preserved by the service or by the library. A new connection attempt can be triggered by an explicit call toConnection.connect(), which results in a new connection.
-
failed
public static final ConnectionState failed
This state is entered if the client library encounters a failure condition that it cannot recover from. This may be a fatal connection error received from the Ably service, for example an attempt to connect with an incorrect API key, or a local terminal error, for example the token in use has expired and the library does not have any way to renew it. In the failed state, no reconnection attempts are made automatically by the library, and clients may not publish messages. A new connection attempt can be triggered by an explicit call toConnection.connect().
-
-
Method Detail
-
values
public static ConnectionState[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ConnectionState c : ConnectionState.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ConnectionState valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
getConnectionEvent
public ConnectionEvent getConnectionEvent()
-
-