Repository navigation
feat(room): emit RoomEvent.TokenRefreshed when the server issues a new token - #2200
ninglinLiu wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: fbd0706 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
|
@lukasIO I would be curious your take on this. As part of the This seems like a similar type of change only applied to the web sdk. Can you go into those concerns again here? As is this looks good to me assuming the premise of exposing an updated token via a public api interface is ok. |
|
@1egoman let's keep the discussion in the related issue |
Closes #2199
Problem
The server refreshes the local participant's access token periodically and after attribute or permission changes (and sends a new one on room moves). The SDK stores it in
RTCEngineand uses it for resumes and full reconnects, but applications can only observe it throughroom.engine.on(EngineEvent.TokenRefreshed, …), andRoom.engineis@internalandEngineEventis not exported. The engine event is also re-emitted with the token it already holds before every reconnect attempt, so a listener has to deduplicate.Change
RoomEvent.TokenRefreshed(tokenRefreshed: (token: string) => voidinRoomEventCallbacks).CoreRoomkeeps the latest token for the local participant (set from the token passed toconnect(), updated on every new server-issued token) and forwardsEngineEvent.TokenRefreshedonly when the token differs, so the reconnect re-emits do not surface as refreshes.regionUrlProvider.updateTokencall is unchanged.Tests
Room.test.ts: re-emitting the join token or the same refreshed token does not fire the event; each new token fires it once.vitest run src/room/Room.test.ts(23 passed),tsc --noEmit, eslint and prettier pass. Includes a minor changeset (new public API).This PR was prepared with AI assistance and reviewed/tested by the author.