Skip to content

Commit e6a533d

Browse files
authored
fix: send unifiedSessionId in the initial join request (#1934)
Provide the `unifiedSessionId` parameter in the initial SFU `JoinRequest`. Ref: GetStream/protocol#1328
1 parent 9f8e555 commit e6a533d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/client/src/Call.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ export class Call {
981981
})
982982
: previousSfuClient;
983983
this.sfuClient = sfuClient;
984+
this.unifiedSessionId ??= sfuClient.sessionId;
984985
this.dynascaleManager.setSfuClient(sfuClient);
985986

986987
const clientDetails = await getClientDetails();
@@ -1008,6 +1009,7 @@ export class Call {
10081009
try {
10091010
const { callState, fastReconnectDeadlineSeconds, publishOptions } =
10101011
await sfuClient.join({
1012+
unifiedSessionId: this.unifiedSessionId,
10111013
subscriberSdp,
10121014
publisherSdp,
10131015
clientDetails,
@@ -1061,6 +1063,7 @@ export class Call {
10611063
statsOptions,
10621064
publishOptions: this.currentPublishOptions || [],
10631065
closePreviousInstances: !performingMigration,
1066+
unifiedSessionId: this.unifiedSessionId,
10641067
});
10651068
}
10661069

@@ -1222,6 +1225,7 @@ export class Call {
12221225
clientDetails: ClientDetails;
12231226
publishOptions: PublishOption[];
12241227
closePreviousInstances: boolean;
1228+
unifiedSessionId: string;
12251229
}) => {
12261230
const {
12271231
sfuClient,
@@ -1230,6 +1234,7 @@ export class Call {
12301234
statsOptions,
12311235
publishOptions,
12321236
closePreviousInstances,
1237+
unifiedSessionId,
12331238
} = opts;
12341239
const { enable_rtc_stats: enableTracing } = statsOptions;
12351240
if (closePreviousInstances && this.subscriber) {
@@ -1288,7 +1293,6 @@ export class Call {
12881293
this.tracer.setEnabled(enableTracing);
12891294
this.sfuStatsReporter?.stop();
12901295
if (statsOptions?.reporting_interval_ms > 0) {
1291-
this.unifiedSessionId ??= sfuClient.sessionId;
12921296
this.sfuStatsReporter = new SfuStatsReporter(sfuClient, {
12931297
clientDetails,
12941298
options: statsOptions,
@@ -1298,7 +1302,7 @@ export class Call {
12981302
camera: this.camera,
12991303
state: this.state,
13001304
tracer: this.tracer,
1301-
unifiedSessionId: this.unifiedSessionId,
1305+
unifiedSessionId,
13021306
});
13031307
this.sfuStatsReporter.start();
13041308
}

packages/client/src/gen/video/sfu/event/events.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,14 @@ export interface JoinRequest {
471471
* @generated from protobuf field: string session_id = 2;
472472
*/
473473
sessionId: string;
474+
/**
475+
* user_session id can change during reconnects, this helps us to
476+
* identify the user across reconnects and should remain consistent until the user explicitly
477+
* disconnects, is kicked or the call is ended.
478+
*
479+
* @generated from protobuf field: string unified_session_id = 13;
480+
*/
481+
unifiedSessionId: string;
474482
/**
475483
* dumb SDP that allow us to extract subscriber's decode codecs
476484
*
@@ -1353,6 +1361,12 @@ class JoinRequest$Type extends MessageType<JoinRequest> {
13531361
super('stream.video.sfu.event.JoinRequest', [
13541362
{ no: 1, name: 'token', kind: 'scalar', T: 9 /*ScalarType.STRING*/ },
13551363
{ no: 2, name: 'session_id', kind: 'scalar', T: 9 /*ScalarType.STRING*/ },
1364+
{
1365+
no: 13,
1366+
name: 'unified_session_id',
1367+
kind: 'scalar',
1368+
T: 9 /*ScalarType.STRING*/,
1369+
},
13561370
{
13571371
no: 3,
13581372
name: 'subscriber_sdp',

0 commit comments

Comments
 (0)