ConnectionListener class provided by the CometChat SDK
Connection Status provides you with the below 3 methods to get the status of the connection to CometChat web-socket servers:
Once the connection is broken, the disconnected callback is triggered, the SDK automatically tries to establish the connection again, thus going into the connecting state and triggering the
connecting method. Once the attempt to connect is successful, the connected method is triggered thus letting the developer know that the connection is established and is active.
In order to use the ConnectionListeners, you need to add the ConnectionListeners using the addConnectionListener method provided by the SDK. You can add multiple listeners as shown below. Just make sure you add listeners with unique IDs.
- Java
- Kotlin
getConnectionStatus property provided by CometChat SDK
- Java
- Kotlin
-
CometChatConstants.WS_STATE_CONNECTED(connected); -
CometChatConstants.WS_STATE_CONNECTING(connecting) -
CometChatConstants.WS_STATE_DISCONNECTED(disconnected) -
CometChatConstants.WS_STATE_FEATURE_THROTTLED(featureThrottled)
Know more about CometChat SDK connection behaviour click here