Session end & token refresh
Silent token renewal, and a clean hand-off to your sign-in screen when an admin ends the session.
Token refresh
Pass refreshToken and the package silently gets a new access token when a request fails with 403 “Invalid or expired token”. You can also set it outside ChatMain with setChatRefreshToken.
Admin-ended session
When an admin signs the user out, deactivates or bans them, or deletes the user or workspace, retrying can never work. The chat disconnects, clears its session and push token, replaces itself with a short explanation (“You've been signed out”, “Account deactivated”, “Access removed”, …) and tells your app. It reacts the same whether the server says so over the socket (session_revoked), on a REST call or when the socket connects (SESSION_REVOKED, ACCOUNT_BANNED, ACCOUNT_DEACTIVATED, WORKSPACE_DELETED):
<ChatMain {...props} onSessionEnd={({ reason, message }) => { // reason: "force_logout" | "deactivated" | "banned" | "deleted" | "workspace_deleted" showSignIn(message); // e.g. "You were signed out by your workspace admin" }}/>Outside React
import { SESSION_ENDED_EVENT, type SessionEnd } from "@realtimexsco/live-chat"; window.addEventListener(SESSION_ENDED_EVENT, (e) => { const { reason, message } = (e as CustomEvent<SessionEnd>).detail;});getApiErrorCode(err) / getApiErrorMessage(err, fallback) read the error code and message from any failed package API call.