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.
To receive real-time connection status, you need to register ConnectionListener wherever you wish to receive the real-time status. You can use the addConnectionListener() method to do so.
- TypeScript
- JavaScript
Listen for Connection Changes
Register aConnectionListener to receive real-time connection state updates. We recommend adding this on app startup after CometChat.init() completes.
- TypeScript
- JavaScript
Next Steps
WebSocket Management
Manually manage WebSocket connections
Login Listener
Listen for login and logout events
All Real-Time Listeners
Complete reference for all SDK listeners
Setup SDK
Install and initialize the CometChat SDK