@reactoo/watchtogether-sdk-js 2.8.53 → 2.8.55

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.
@@ -56177,8 +56177,9 @@ function _connectionClosed() {
56177
56177
  } else if (!this.isDisconnecting) {
56178
56178
  this.disconnect().catch(() => {});
56179
56179
  }
56180
+ } else {
56181
+ this.emit('error', e);
56180
56182
  }
56181
- this.emit('error', e);
56182
56183
  });
56183
56184
  }
56184
56185
  function _wipeListeners() {
@@ -56846,13 +56847,26 @@ async function _webSocketConnection(reclaim = false) {
56846
56847
  this.isEstablishingConnection = false;
56847
56848
  });
56848
56849
  } else {
56850
+ this.emit('reclaimingConnection', {
56851
+ state: true,
56852
+ status: null
56853
+ });
56849
56854
  _assertClassBrand(_RoomSession_brand, this, _send).call(this, {
56850
56855
  "janus": "claim"
56851
56856
  }).then(json => {
56852
56857
  this.sessionId = json["session_id"] ? json["session_id"] : json.data["id"];
56853
56858
  _assertClassBrand(_RoomSession_brand, this, _startKeepAlive).call(this);
56859
+ this.emit('reclaimingConnection', {
56860
+ state: false,
56861
+ status: 'success'
56862
+ });
56854
56863
  resolve(json);
56855
56864
  }).catch(error => {
56865
+ this.emit('reclaimingConnection', {
56866
+ state: false,
56867
+ status: 'failed',
56868
+ error
56869
+ });
56856
56870
  reject({
56857
56871
  type: 'error',
56858
56872
  id: 17,
@@ -56867,6 +56881,11 @@ async function _webSocketConnection(reclaim = false) {
56867
56881
  this.ws.onerror = e => {
56868
56882
  this.isEstablishingConnection = false;
56869
56883
  this._abortController.signal.removeEventListener('abort', abortConnect);
56884
+ this.emit('reclaimingConnection', {
56885
+ state: false,
56886
+ status: 'failed',
56887
+ error: e
56888
+ });
56870
56889
  reject({
56871
56890
  type: 'error',
56872
56891
  id: 18,
@@ -56915,14 +56934,27 @@ async function _httpConnection(reclaim = false) {
56915
56934
  this.isEstablishingConnection = false;
56916
56935
  });
56917
56936
  } else {
56937
+ this.emit('reclaimingConnection', {
56938
+ state: true,
56939
+ status: null
56940
+ });
56918
56941
  return _assertClassBrand(_RoomSession_brand, this, _send).call(this, {
56919
56942
  "janus": "claim"
56920
56943
  }).then(json => {
56921
56944
  this.sessionId = json["session_id"] ? json["session_id"] : json.data["id"];
56922
56945
  _assertClassBrand(_RoomSession_brand, this, _startKeepAlive).call(this);
56923
56946
  _assertClassBrand(_RoomSession_brand, this, _longPoll).call(this);
56947
+ this.emit('reclaimingConnection', {
56948
+ state: false,
56949
+ status: 'success'
56950
+ });
56924
56951
  return this;
56925
56952
  }).catch(error => {
56953
+ this.emit('reclaimingConnection', {
56954
+ state: false,
56955
+ status: 'failed',
56956
+ error
56957
+ });
56926
56958
  return Promise.reject({
56927
56959
  type: 'error',
56928
56960
  id: 21,
@@ -56971,26 +57003,17 @@ async function _waitForConnectEvent() {
56971
57003
  });
56972
57004
  }
56973
57005
  async function _reconnect() {
56974
- if (this.isConnecting) {
57006
+ if (this.isEstablishingConnection) {
56975
57007
  return Promise.reject({
56976
57008
  type: 'warning',
56977
57009
  id: 22,
56978
57010
  message: 'connection already in progress'
56979
57011
  });
56980
57012
  }
56981
- this.isConnecting = true;
56982
57013
  if (this.useWebsockets) {
56983
- try {
56984
- await _assertClassBrand(_RoomSession_brand, this, _webSocketConnection).call(this, true);
56985
- } finally {
56986
- this.isConnecting = false;
56987
- }
57014
+ await _assertClassBrand(_RoomSession_brand, this, _webSocketConnection).call(this, true);
56988
57015
  } else {
56989
- try {
56990
- await _assertClassBrand(_RoomSession_brand, this, _httpConnection).call(this, true);
56991
- } finally {
56992
- this.isConnecting = false;
56993
- }
57016
+ await _assertClassBrand(_RoomSession_brand, this, _httpConnection).call(this, true);
56994
57017
  }
56995
57018
  }
56996
57019
  function _enableDebug2() {
@@ -57363,6 +57386,11 @@ function _iceRestart(handleId) {
57363
57386
  config.isIceRestarting = true;
57364
57387
  if (this.handleId === handleId) {
57365
57388
  this._log('Performing local ICE restart');
57389
+ this.emit('iceRestart', {
57390
+ state: true,
57391
+ origin: 'local',
57392
+ status: null
57393
+ });
57366
57394
  const hasAudio = !!(config.stream && config.stream.getAudioTracks().length > 0);
57367
57395
  const hasVideo = !!(config.stream && config.stream.getVideoTracks().length > 0);
57368
57396
  _assertClassBrand(_RoomSession_brand, this, _createAO).call(this, 'offer', handleId, true).then(jsep => {
@@ -57384,9 +57412,21 @@ function _iceRestart(handleId) {
57384
57412
  }, false, false, 5);
57385
57413
  }).then(r => {
57386
57414
  config.isIceRestarting = false;
57387
- this._log('ICE restart success');
57415
+ this._log('Local ICE restart success');
57416
+ this.emit('iceRestart', {
57417
+ state: false,
57418
+ origin: 'local',
57419
+ status: 'success'
57420
+ });
57388
57421
  }).catch(e => {
57389
57422
  config.isIceRestarting = false;
57423
+ this._log('Local ICE restart failed', e);
57424
+ this.emit('iceRestart', {
57425
+ state: false,
57426
+ origin: 'local',
57427
+ status: 'failed',
57428
+ error: e
57429
+ });
57390
57430
  if (this.isSupposeToBeConnected) {
57391
57431
  this.emit('restartConnection');
57392
57432
  (0,_models_utils__WEBPACK_IMPORTED_MODULE_2__.wait)(10000).then(() => {
@@ -57406,6 +57446,11 @@ function _iceRestart(handleId) {
57406
57446
  });
57407
57447
  } else {
57408
57448
  this._log('Performing remote ICE restart', handleId);
57449
+ this.emit('iceRestart', {
57450
+ state: true,
57451
+ origin: 'remote',
57452
+ status: null
57453
+ });
57409
57454
  return this.sendMessage(handleId, {
57410
57455
  body: {
57411
57456
  "request": "configure",
@@ -57413,9 +57458,21 @@ function _iceRestart(handleId) {
57413
57458
  }
57414
57459
  }, false, false, 5).then(() => {}).then(() => {
57415
57460
  config.isIceRestarting = false;
57416
- this._log('ICE restart success');
57417
- }).catch(() => {
57461
+ this.emit('iceRestart', {
57462
+ state: false,
57463
+ origin: 'remote',
57464
+ status: 'success'
57465
+ });
57466
+ this._log('Remote ICE restart success');
57467
+ }).catch(e => {
57418
57468
  config.isIceRestarting = false;
57469
+ this.emit('iceRestart', {
57470
+ state: false,
57471
+ origin: 'remote',
57472
+ status: 'failed',
57473
+ error: e
57474
+ });
57475
+ this._log('Remote ICE restart failed');
57419
57476
  });
57420
57477
  }
57421
57478
  }