ChatNotificationsClient
Defined in: core/client.ts:44
Subscribes to a user’s own Chat realtime notifications
(message.created, typing, presence.updated — see
docs/notifications.md) without depending on any external library. Talks
to the backend’s context-scoped
GET /tenants/:tenant_id/applications/:application_id/notifications/realtime-token endpoint to
get a ready-to-open stream URL — the backend does the realtime vendor’s
entire handshake server-side, so this class never knows or cares which
vendor is behind it — then opens it with the browser’s native
EventSource. No vendor SDK, no vendor config, no bundle-size cost, no
vendor-specific type ever appears in this class’s public surface.
One connection always carries the caller’s personal channel and the broadcast topics of the
CHANNEL conversations they are a member of, plus (optionally) one more PUBLIC CHANNEL
conversation via subscribeToConversation/unsubscribeFromConversation — matching the backend’s
realtime-token?conversation_id=<id> capability, which accepts only one conversation id at a
time. Changing that, or a proactive token refresh, closes and reopens the stream — SSE has no
way to add/remove channels on a live connection.
The same reopen happens automatically when this user gains a CHANNEL conversation (a
conversation.created for a CHANNEL, or their own member.added), since the current stream’s
credential predates that membership and so lacks the conversation’s broadcast topic.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ChatNotificationsClient(
options):ChatNotificationsClient
Defined in: core/client.ts:64
Parameters
Section titled “Parameters”options
Section titled “options”ChatNotificationsClientOptions
Returns
Section titled “Returns”ChatNotificationsClient
Accessors
Section titled “Accessors”connectionState
Section titled “connectionState”Get Signature
Section titled “Get Signature”get connectionState():
ConnectionState
Defined in: core/client.ts:97
Returns
Section titled “Returns”Methods
Section titled “Methods”on<
K>(event,handler):Unsubscribe
Defined in: core/client.ts:101
Type Parameters
Section titled “Type Parameters”K extends keyof ChatNotificationEventMap | "connectionStateChange"
Parameters
Section titled “Parameters”K
handler
Section titled “handler”(payload) => void
Returns
Section titled “Returns”connect()
Section titled “connect()”connect():
void
Defined in: core/client.ts:105
Returns
Section titled “Returns”void
disconnect()
Section titled “disconnect()”disconnect():
void
Defined in: core/client.ts:114
Returns
Section titled “Returns”void
subscribeToConversation()
Section titled “subscribeToConversation()”subscribeToConversation(
conversationId):void
Defined in: core/client.ts:124
Adds one CHANNEL conversation’s broadcast topic (e.g. a PUBLIC channel being viewed) — replaces any previously added one.
Parameters
Section titled “Parameters”conversationId
Section titled “conversationId”string
Returns
Section titled “Returns”void
unsubscribeFromConversation()
Section titled “unsubscribeFromConversation()”unsubscribeFromConversation(
conversationId):void
Defined in: core/client.ts:134
Parameters
Section titled “Parameters”conversationId
Section titled “conversationId”string
Returns
Section titled “Returns”void