Skip to main content

Documentation Index

Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

The CometChat SDK maintains a persistent WebSocket connection for real-time events. The OnConnectionStateChanged delegate lets you track the connection lifecycle and show appropriate UI (e.g., a “Reconnecting…” banner).

Listen for Connection Changes

  1. Get a reference to the CometChat Subsystem
  2. Drag off and search for On Connection State Changed
  3. Use Bind Event to connect it to a custom event
  4. The custom event receives an ECometChatConnectionState enum value

ECometChatConnectionState

ValueDescription
ConnectedWebSocket is active. Real-time events (messages, presence, typing, receipts) are flowing.
DisconnectedWebSocket is closed. No real-time events will be received until reconnection.
ReconnectingThe SDK detected a disconnect and is automatically attempting to reconnect.

Reconnection Behavior

The SDK handles reconnection automatically:
  1. When the WebSocket drops (network change, server timeout, etc.), the state moves to Reconnecting
  2. The SDK retries with exponential backoff
  3. On successful reconnection, the state moves back to Connected
  4. If reconnection fails permanently, the state moves to Disconnected
UI pattern: Show a subtle banner at the top of your chat screen when the state is Disconnected or Reconnecting. Hide it when Connected fires again. This gives players confidence that the chat system is working.
While disconnected, you can still call async nodes like Get Messages Async — those use HTTP requests, not the WebSocket. Only real-time push events are affected by the connection state.

Next Steps

Real-Time Events

See all five real-time delegates in one place.

API Reference

Complete reference of all nodes, structs, and enums.