@reactoo/watchtogether-sdk-js 2.8.53 → 2.8.54

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