From edc9440e00ff51d100f27c3bf61e68dc4d467af4 Mon Sep 17 00:00:00 2001 From: Oliver Lazoroski Date: Wed, 24 Sep 2025 10:43:43 +0200 Subject: [PATCH] fix: send unifiedSessionId in the initial join request --- packages/client/src/Call.ts | 8 ++++++-- packages/client/src/gen/video/sfu/event/events.ts | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/client/src/Call.ts b/packages/client/src/Call.ts index ae3ba68569..b8e1a14d25 100644 --- a/packages/client/src/Call.ts +++ b/packages/client/src/Call.ts @@ -981,6 +981,7 @@ export class Call { }) : previousSfuClient; this.sfuClient = sfuClient; + this.unifiedSessionId ??= sfuClient.sessionId; this.dynascaleManager.setSfuClient(sfuClient); const clientDetails = await getClientDetails(); @@ -1008,6 +1009,7 @@ export class Call { try { const { callState, fastReconnectDeadlineSeconds, publishOptions } = await sfuClient.join({ + unifiedSessionId: this.unifiedSessionId, subscriberSdp, publisherSdp, clientDetails, @@ -1061,6 +1063,7 @@ export class Call { statsOptions, publishOptions: this.currentPublishOptions || [], closePreviousInstances: !performingMigration, + unifiedSessionId: this.unifiedSessionId, }); } @@ -1222,6 +1225,7 @@ export class Call { clientDetails: ClientDetails; publishOptions: PublishOption[]; closePreviousInstances: boolean; + unifiedSessionId: string; }) => { const { sfuClient, @@ -1230,6 +1234,7 @@ export class Call { statsOptions, publishOptions, closePreviousInstances, + unifiedSessionId, } = opts; const { enable_rtc_stats: enableTracing } = statsOptions; if (closePreviousInstances && this.subscriber) { @@ -1288,7 +1293,6 @@ export class Call { this.tracer.setEnabled(enableTracing); this.sfuStatsReporter?.stop(); if (statsOptions?.reporting_interval_ms > 0) { - this.unifiedSessionId ??= sfuClient.sessionId; this.sfuStatsReporter = new SfuStatsReporter(sfuClient, { clientDetails, options: statsOptions, @@ -1298,7 +1302,7 @@ export class Call { camera: this.camera, state: this.state, tracer: this.tracer, - unifiedSessionId: this.unifiedSessionId, + unifiedSessionId, }); this.sfuStatsReporter.start(); } diff --git a/packages/client/src/gen/video/sfu/event/events.ts b/packages/client/src/gen/video/sfu/event/events.ts index cafec82f7b..12d102d5cd 100644 --- a/packages/client/src/gen/video/sfu/event/events.ts +++ b/packages/client/src/gen/video/sfu/event/events.ts @@ -471,6 +471,14 @@ export interface JoinRequest { * @generated from protobuf field: string session_id = 2; */ sessionId: string; + /** + * user_session id can change during reconnects, this helps us to + * identify the user across reconnects and should remain consistent until the user explicitly + * disconnects, is kicked or the call is ended. + * + * @generated from protobuf field: string unified_session_id = 13; + */ + unifiedSessionId: string; /** * dumb SDP that allow us to extract subscriber's decode codecs * @@ -1353,6 +1361,12 @@ class JoinRequest$Type extends MessageType { super('stream.video.sfu.event.JoinRequest', [ { no: 1, name: 'token', kind: 'scalar', T: 9 /*ScalarType.STRING*/ }, { no: 2, name: 'session_id', kind: 'scalar', T: 9 /*ScalarType.STRING*/ }, + { + no: 13, + name: 'unified_session_id', + kind: 'scalar', + T: 9 /*ScalarType.STRING*/, + }, { no: 3, name: 'subscriber_sdp',