@stream-io/video-client 0.0.47 → 0.0.48

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.
package/dist/index.cjs.js CHANGED
@@ -6341,10 +6341,10 @@ class Publisher {
6341
6341
  /**
6342
6342
  * Restarts the ICE connection and renegotiates with the SFU.
6343
6343
  */
6344
- this.restartIce = () => {
6344
+ this.restartIce = () => __awaiter(this, void 0, void 0, function* () {
6345
6345
  this.logger('debug', 'Restarting ICE connection');
6346
- this.pc.restartIce();
6347
- };
6346
+ yield this.negotiate({ iceRestart: true });
6347
+ });
6348
6348
  this.onNegotiationNeeded = () => __awaiter(this, void 0, void 0, function* () {
6349
6349
  yield this.negotiate();
6350
6350
  });
@@ -6486,10 +6486,27 @@ class Publisher {
6486
6486
  };
6487
6487
  this.onIceConnectionStateChange = () => {
6488
6488
  const state = this.pc.iceConnectionState;
6489
- this.logger('debug', `ICE Connection state changed`, state);
6490
- if (state === 'failed' || state === 'disconnected') {
6491
- this.logger('warn', `ICE Connection state changed to ${state}. Attempting to restart ICE`);
6492
- this.restartIce();
6489
+ this.logger('debug', `ICE Connection state changed to`, state);
6490
+ if (state === 'failed') {
6491
+ this.logger('warn', `Attempting to restart ICE`);
6492
+ this.restartIce().catch((e) => {
6493
+ this.logger('error', `ICE restart error`, e);
6494
+ });
6495
+ }
6496
+ else if (state === 'disconnected') {
6497
+ // when in `disconnected` state, the browser may recover automatically,
6498
+ // hence, we delay the ICE restart
6499
+ this.logger('warn', `Scheduling ICE restart in 5 seconds`);
6500
+ setTimeout(() => {
6501
+ // check if the state is still `disconnected` or `failed`
6502
+ // as the connection may have recovered (or failed) in the meantime
6503
+ if (this.pc.iceConnectionState === 'disconnected' ||
6504
+ this.pc.iceConnectionState === 'failed') {
6505
+ this.restartIce().catch((e) => {
6506
+ this.logger('error', `ICE restart error`, e);
6507
+ });
6508
+ }
6509
+ }, 5000);
6493
6510
  }
6494
6511
  };
6495
6512
  this.onIceGatheringStateChange = () => {
@@ -11332,7 +11349,7 @@ class WSConnectionFallback {
11332
11349
  }
11333
11350
  }
11334
11351
 
11335
- const version = '0.0.47';
11352
+ const version = '0.0.48';
11336
11353
 
11337
11354
  const logger = getLogger(['location']);
11338
11355
  const HINT_URL = `https://hint.stream-io-video.com/`;