Package io.ably.lib.transport
Class ConnectionManager
- java.lang.Object
-
- io.ably.lib.transport.ConnectionManager
-
- All Implemented Interfaces:
ITransport.ConnectListener
public class ConnectionManager extends java.lang.Object implements ITransport.ConnectListener
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceConnectionManager.ChannelsMethods on the channels map owned by theAblyRealtimeinstance which theConnectionManagerneeds access to.static classConnectionManager.QueuedMessageevent queueingclassConnectionManager.Statea class encapsulating state machine information for a given statestatic classConnectionManager.StateIndicationa class encapsulating information associated with a currentState change request or notification
-
Constructor Summary
Constructors Constructor Description ConnectionManager(AblyRealtime ably, Connection connection, ConnectionManager.Channels channels, PlatformAgentProvider platformAgentProvider)ConnectionManager
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancheckConnectivity()Determine whether or not the client has connection to the network without reference to a specific ably host.voidclose()voidconnect()ConnectionManager.StategetConnectionState()states APIjava.lang.StringgetHost()host managementErrorInfogetStateErrorInfo()booleanisActive()voidonAuthError(ErrorInfo errorInfo)Called when where was an error during authentication attemptvoidonAuthUpdated(java.lang.String token, boolean waitForResponse)(RTC8) For a realtime client, Auth.authorize instructs the library to obtain a token using the provided tokenParams and authOptions and upgrade the current connection to use that token; or if not currently connected, to connect with the token.voidonAuthUpdatedAsync(java.lang.String token, Auth.AuthUpdateResult authUpdateResult)Async version of onAuthUpdated that returns a Future that includes an option Ably exceptionvoidonMessage(ITransport transport, ProtocolMessage message)React on message from the transportvoidonTransportAvailable(ITransport transport)voidonTransportUnavailable(ITransport transport, ErrorInfo reason)voidping(CompletionListener listener)ping APIvoidrequestState(ConnectionState state)voidrequestState(ConnectionManager.StateIndication state)voidsend(ProtocolMessage msg, boolean queueEvents, CompletionListener listener)protected voidsetLastActivity(long lastActivityTime)
-
-
-
Constructor Detail
-
ConnectionManager
public ConnectionManager(AblyRealtime ably, Connection connection, ConnectionManager.Channels channels, PlatformAgentProvider platformAgentProvider) throws AblyException
ConnectionManager- Throws:
AblyException
-
-
Method Detail
-
getStateErrorInfo
public ErrorInfo getStateErrorInfo()
-
isActive
public boolean isActive()
-
getHost
public java.lang.String getHost()
host management
-
getConnectionState
public ConnectionManager.State getConnectionState()
states API
-
connect
public void connect()
-
close
public void close()
-
requestState
public void requestState(ConnectionState state)
-
requestState
public void requestState(ConnectionManager.StateIndication state)
-
ping
public void ping(CompletionListener listener)
ping API
-
onAuthUpdated
public void onAuthUpdated(java.lang.String token, boolean waitForResponse) throws AblyException(RTC8) For a realtime client, Auth.authorize instructs the library to obtain a token using the provided tokenParams and authOptions and upgrade the current connection to use that token; or if not currently connected, to connect with the token.- Throws:
AblyException
-
onAuthUpdatedAsync
public void onAuthUpdatedAsync(java.lang.String token, Auth.AuthUpdateResult authUpdateResult)Async version of onAuthUpdated that returns a Future that includes an option Ably exception
-
onAuthError
public void onAuthError(ErrorInfo errorInfo)
Called when where was an error during authentication attempt- Parameters:
errorInfo- Error associated with unsuccessful authentication
-
onMessage
public void onMessage(ITransport transport, ProtocolMessage message) throws AblyException
React on message from the transport- Parameters:
transport- transport instance or null to bypass transport correctness check (for testing)message-- Throws:
AblyException
-
onTransportAvailable
public void onTransportAvailable(ITransport transport)
- Specified by:
onTransportAvailablein interfaceITransport.ConnectListener
-
onTransportUnavailable
public void onTransportUnavailable(ITransport transport, ErrorInfo reason)
- Specified by:
onTransportUnavailablein interfaceITransport.ConnectListener
-
checkConnectivity
protected boolean checkConnectivity()
Determine whether or not the client has connection to the network without reference to a specific ably host. This is to determine whether it is better to try a fallback host, or keep retrying with the default host.- Returns:
- boolean, true if network is available
-
setLastActivity
protected void setLastActivity(long lastActivityTime)
-
send
public void send(ProtocolMessage msg, boolean queueEvents, CompletionListener listener) throws AblyException
- Throws:
AblyException
-
-