@stream-io/video-client 1.19.2 → 1.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -109,7 +109,12 @@ export declare class Call {
109
109
  * method to construct a `Call` instance.
110
110
  */
111
111
  constructor({ type, id, streamClient, members, ownCapabilities, sortParticipantsBy, clientStore, ringing, watching, }: CallConstructor);
112
- private setup;
112
+ /**
113
+ * Sets up the call instance.
114
+ *
115
+ * @internal an internal method and should not be used outside the SDK.
116
+ */
117
+ setup: () => Promise<void>;
113
118
  private registerEffects;
114
119
  private handleOwnCapabilitiesUpdated;
115
120
  /**
@@ -70,6 +70,10 @@ export declare class StreamSfuClient {
70
70
  * This is set to `true` when the user initiates the leave process.
71
71
  */
72
72
  isLeaving: boolean;
73
+ /**
74
+ * Flag to indicate if the client is in the process of closing the connection.
75
+ */
76
+ isClosing: boolean;
73
77
  private readonly rpc;
74
78
  private keepAliveInterval?;
75
79
  private connectionCheckTimeout?;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "1.19.2",
3
+ "version": "1.19.3",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.es.js",
6
6
  "browser": "dist/index.browser.es.js",
package/src/Call.ts CHANGED
@@ -315,7 +315,12 @@ export class Call {
315
315
  this.dynascaleManager = new DynascaleManager(this.state, this.speaker);
316
316
  }
317
317
 
318
- private setup = async () => {
318
+ /**
319
+ * Sets up the call instance.
320
+ *
321
+ * @internal an internal method and should not be used outside the SDK.
322
+ */
323
+ setup = async () => {
319
324
  await withoutConcurrency(this.joinLeaveConcurrencyTag, async () => {
320
325
  if (this.initialized) return;
321
326
 
@@ -1309,7 +1314,7 @@ export class Call {
1309
1314
  )
1310
1315
  return;
1311
1316
  // normal close, no need to reconnect
1312
- if (sfuClient.isLeaving) return;
1317
+ if (sfuClient.isLeaving || sfuClient.isClosing) return;
1313
1318
  this.reconnect(WebsocketReconnectStrategy.REJOIN, reason).catch((err) => {
1314
1319
  this.logger('warn', '[Reconnect] Error reconnecting', err);
1315
1320
  });
@@ -1583,9 +1588,10 @@ export class Call {
1583
1588
  },
1584
1589
  );
1585
1590
 
1586
- this.leaveCallHooks.add(unregisterGoAway);
1587
- this.leaveCallHooks.add(unregisterOnError);
1588
- this.leaveCallHooks.add(unregisterNetworkChanged);
1591
+ this.leaveCallHooks
1592
+ .add(unregisterGoAway)
1593
+ .add(unregisterOnError)
1594
+ .add(unregisterNetworkChanged);
1589
1595
  };
1590
1596
 
1591
1597
  /**
@@ -118,6 +118,11 @@ export class StreamSfuClient {
118
118
  */
119
119
  isLeaving = false;
120
120
 
121
+ /**
122
+ * Flag to indicate if the client is in the process of closing the connection.
123
+ */
124
+ isClosing = false;
125
+
121
126
  private readonly rpc: SignalServerClient;
122
127
  private keepAliveInterval?: number;
123
128
  private connectionCheckTimeout?: NodeJS.Timeout;
@@ -288,6 +293,7 @@ export class StreamSfuClient {
288
293
  };
289
294
 
290
295
  close = (code: number = StreamSfuClient.NORMAL_CLOSURE, reason?: string) => {
296
+ this.isClosing = true;
291
297
  if (this.signalWs.readyState === WebSocket.OPEN) {
292
298
  this.logger('debug', `Closing SFU WS connection: ${code} - ${reason}`);
293
299
  this.signalWs.close(code, `js-client: ${reason}`);
@@ -406,6 +406,7 @@ export class StreamVideoClient {
406
406
  call.state.updateFromCallResponse(c.call);
407
407
  await call.applyDeviceConfig(c.call.settings, false);
408
408
  if (data.watch) {
409
+ await call.setup();
409
410
  this.writeableStateStore.registerCall(call);
410
411
  }
411
412
  calls.push(call);