AI Integration Quick Reference
AI Integration Quick Reference
| Delegate Method | Information |
|---|---|
| connecting | This method is triggered when CometChat SDK is trying to establish a connection to the web-socket server. |
| connected | This method is called when CometChat SDK has successfully established a connection and now is connected. |
| disconnected | This method is called when the CometChat SDK gets disconnected due to any issue while maintaining the connection like network fluctuations, etc. |
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.
- Connection Listener
- TypeScript
We recommend you to add the Connection Listener in your method on app startup, preferably in the index.js file. Once you have successfully initialized CometChat.
getConnectionStatus property provided by CometChat SDK
- Get Connection Status
- TypeScript
CometChat.getConnectionStatus method will return either of the below 3 values:
- connecting
- connected
- disconnected
getConnectionStatus() return string enum values representing the current WebSocket connection state:
| Value | Callback | Description |
|---|---|---|
"connected" | onConnected() | SDK has an active connection to CometChat servers |
"connecting" | inConnecting() | SDK is attempting to establish or re-establish a connection |
"disconnected" | onDisconnected() | SDK is disconnected due to network issues or other errors |
"featureThrottled" | — | A feature has been throttled due to rate limiting |
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