The Sceyt Chat SDK communicates over a persistent WebSocket connection. Your application is responsible for explicitly opening and closing that connection at the right moments in the activity or user-session lifecycle. This page walks through every connection-related API the UIKit exposes, explains when each one should be called, and shows how to observe real-time connection state changes and handle token expiry events gracefully.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sceyt/sceyt-chat-android-uikit/llms.txt
Use this file to discover all available pages before exploring further.
Connecting
CallSceytChatUIKit.connect() after a user successfully authenticates. Pass the short-lived JWT token you obtained from your backend. The SDK hands the token to the underlying ChatClient, which opens the WebSocket, authenticates the session, and begins syncing channel state.
connect() is non-blocking. The WebSocket handshake happens asynchronously. Use ConnectionEventManager.onChangedConnectStatusFlow (described below) to react once the connection is actually established.Reconnecting
SceytChatUIKit.reconnect() tells the ChatClient to attempt a new connection using the last-known credentials without supplying a new token. Use this in scenarios where you know the token is still valid but the WebSocket dropped — for example, after the device recovers from a brief network interruption detected by a ConnectivityManager callback.
Disconnecting
SceytChatUIKit.disconnect() closes the WebSocket cleanly without clearing any local database state or push registrations. The user’s cached messages and channel list remain intact on device; they are simply no longer receiving live updates.
Calling
disconnect() does not log the user out. Local data and push-notification registration are preserved. Call connect() again to resume the session.Logging out
SceytChatUIKit.logOut() performs a full session teardown: it cancels in-progress sync workers, clears the Room database, removes all channel and user caches, unregisters the device’s Firebase push token from Sceyt’s servers, and then disconnects the WebSocket. Use this when the user explicitly signs out of your application.
An optional lambda invoked after the asynchronous Firebase token unregistration attempt completes. Receives a
Result<Boolean> — success(true) when the server confirmed unregistration, or failure(exception) when it could not be completed. The user is fully logged out locally regardless of this result.Monitoring connection state
ConnectionEventManager is a singleton in com.sceyt.chatuikit.data.managers.connection that exposes real-time connection state as Kotlin Flows and convenience properties.
Quick state checks
Collecting the state flow
onChangedConnectStatusFlow is a SharedFlow<ConnectionStateData> that replays the most recent emission to new collectors, making it safe to subscribe at any point in your lifecycle:
Awaiting connection in suspend functions
ConnectionEventManager also provides suspending helpers for use in coroutines:
Handling token expiry
Sceyt tokens are short-lived. The SDK notifies your application through twoSharedFlow properties on SceytChatUIFacade — accessible as SceytChatUIKit.chatUIFacade:
| Flow | Emits | Meaning |
|---|---|---|
onTokenWillExpire | Unit | The current token will expire soon. Fetch a new one proactively. |
onTokenExpired | Unit | The token has already expired. The connection will drop unless a new token is supplied. |
Application scope or a retained ViewModel):
Refreshing the token manually
SceytChatUIFacade.updateToken() delivers a fresh token to the SDK without requiring a full reconnect cycle. It wraps ChatClient.updateToken() and notifies you of the outcome via a lambda: