For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
ReferenceGuidesClick-to-Call
ReferenceGuidesClick-to-Call
  • Core
    • Overview
  • SignalWire Client
    • Overview
    • Notifications
    • Client
    • Utility functions
  • Video
    • Overview
    • LocalOverlay
    • RoomSession
    • RoomSessionDevice
    • RoomSessionPlayback
    • RoomSessionRecording
    • RoomSessionScreenShare
    • RoomSessionStream
    • RoomDevice
    • RoomScreenShare
  • Chat
    • Overview
    • Client
    • ChatMember
    • ChatMemberEntity
    • ChatMessage
    • ChatMessageEntity
  • PubSub
    • Overview
    • Client
      • Events
        • disconnect
        • getAllowedChannels
        • off
        • on
        • once
        • publish
        • removeAllListeners
        • subscribe
        • unsubscribe
        • updateToken
    • PubSubMessage
  • WebRTC
    • Overview
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • updateToken
PubSubClientMethods

updateToken

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

PubSubMessage

Next
Built with

updateToken

  • updateToken(token): Promise<void>

Replaces the token used by the client with a new one. You can use this method to replace the token when, for example, it is expiring, in order to keep the session alive.

The new token can contain different channels from the previous one. In that case, you will need to subscribe to the new channels if you want to receive messages for those. Channels that were in the previous token but are not in the new one will get unsubscribed automatically.

Parameters

token
stringRequired

The new token.

Returns

Promise<void>

Example

1const pubSubClient = new PubSub.Client({
2 token: '<your chat token>'
3})
4
5pubSubClient.on('session.expiring', async () => {
6 const newToken = await fetchNewToken(..)
7
8 await pubSubClient.updateToken(newToken)
9})