RealTimeX
Sign inStart for free
RealTimeXWeb Package
IntroductionPrerequisitesInstallationProject setupQuick start
Package structureConfigurationComponentsHooksAPI integrationSocket events
OverviewReplace entire UIReplace componentsStyle with classNamesThemes & localePhone & video callingIn-call control barFeatures
Unread badgeRich-text messagesPins, stars & datesMessage threadsMentionsCanvas & draftsNotificationsAdmin permissionsServer refusalsSession & token refresh
Host app integrationTroubleshootingFAQVersion historyBest practicesSupport & contact
Web packageBuilt-in features

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):

tsx
1<ChatMain2  {...props}3  onSessionEnd={({ reason, message }) => {4    // reason: "force_logout" | "deactivated" | "banned" | "deleted" | "workspace_deleted"5    showSignIn(message); // e.g. "You were signed out by your workspace admin"6  }}7/>

Outside React

typescript
1import { SESSION_ENDED_EVENT, type SessionEnd } from "@realtimexsco/live-chat";2 3window.addEventListener(SESSION_ENDED_EVENT, (e) => {4  const { reason, message } = (e as CustomEvent<SessionEnd>).detail;5});

getApiErrorCode(err) / getApiErrorMessage(err, fallback) read the error code and message from any failed package API call.

PreviousServer refusalsNextHost app integration

On this page

Token refreshAdmin-ended sessionOutside React
Back to top