Skip to main content
// Check connection status
CometChat.getConnectionStatus(); // "connected" | "connecting" | "disconnected"

// Listen for connection changes
CometChat.addConnectionListener("LISTENER_ID", new CometChat.ConnectionListener({
  onConnected: () => console.log("Connected"),
  onDisconnected: () => console.log("Disconnected")
}));

// Listen for login events
CometChat.addLoginListener("LISTENER_ID", new CometChat.LoginListener({
  onLoginSuccess: (user) => console.log("Logged in:", user),
  onLogoutSuccess: () => console.log("Logged out")
}));
This section helps you to know about the Connection Listeners.

Next Steps

Connection Status

Monitor and respond to connection state changes

WebSocket Management

Manually manage WebSocket connections

Login Listener

Listen for login and logout events

All Real-Time Listeners

Complete reference for all SDK listeners