@reactoo/watchtogether-sdk-js 2.7.91 → 2.7.92-beta.1

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.
@@ -9874,6 +9874,7 @@ class RoomSession {
9874
9874
  this.isConnecting = false;
9875
9875
  this.isDisconnecting = false;
9876
9876
  this.isConnected = false;
9877
+ this.isPossibleToPublish = false; // we added this because joined event happened after we fired publish, im' not sure what relies on current event based isConnected flag so i've added a new one
9877
9878
  this.isPublished = false;
9878
9879
  this.isStreaming = false;
9879
9880
  this.isMuted = [];
@@ -10363,6 +10364,7 @@ class RoomSession {
10363
10364
  this.id = msg["id"];
10364
10365
  this.privateId = msg["private_id"];
10365
10366
  this.isConnected = true;
10367
+ this.isPossibleToPublish = true;
10366
10368
  this._log('We have successfully joined Room');
10367
10369
  this.emit('joined', true, this.constructId);
10368
10370
  this.emit('addLocalParticipant', {
@@ -10973,6 +10975,7 @@ class RoomSession {
10973
10975
  }
10974
10976
  }, dontWait).finally(() => {
10975
10977
  this.isConnected = false;
10978
+ this.isPossibleToPublish = false;
10976
10979
  this.emit('joined', false);
10977
10980
  }) : Promise.resolve();
10978
10981
  }
@@ -10985,6 +10988,7 @@ class RoomSession {
10985
10988
  message: 'connection establishment already in progress'
10986
10989
  });
10987
10990
  }
10991
+ this.isPossibleToPublish = false;
10988
10992
  this.isConnecting = true;
10989
10993
  this.emit('joining', true);
10990
10994
  if (this.ws) {
@@ -11031,6 +11035,7 @@ class RoomSession {
11031
11035
  this._enableStatsWatch();
11032
11036
  this._enableSubstreamAutoSelect();
11033
11037
  this.isConnecting = false;
11038
+ this.isPossibleToPublish = true;
11034
11039
  this.emit('joining', false);
11035
11040
  resolve(this);
11036
11041
  }).catch(error => {
@@ -11081,6 +11086,23 @@ class RoomSession {
11081
11086
  }
11082
11087
  _httpConnection() {
11083
11088
  let reclaim = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11089
+ if (this.isConnecting) {
11090
+ return Promise.reject({
11091
+ type: 'warning',
11092
+ id: 16,
11093
+ message: 'connection establishment already in progress'
11094
+ });
11095
+ }
11096
+ this.isPossibleToPublish = false;
11097
+ this.isConnecting = true;
11098
+ this.emit('joining', true);
11099
+ if (this.ws) {
11100
+ this._wipeListeners();
11101
+ if (this.ws.readyState === 1) {
11102
+ this.ws.close();
11103
+ }
11104
+ }
11105
+ this._stopKeepAlive();
11084
11106
  if (!reclaim) {
11085
11107
  return this._send({
11086
11108
  "janus": "create"
@@ -11097,6 +11119,7 @@ class RoomSession {
11097
11119
  this._enableSubstreamAutoSelect();
11098
11120
  this._longPoll();
11099
11121
  this.isConnecting = false;
11122
+ this.isPossibleToPublish = true;
11100
11123
  this.emit('joining', false);
11101
11124
  return Promise.resolve(this);
11102
11125
  }).catch(error => {
@@ -11197,6 +11220,7 @@ class RoomSession {
11197
11220
  return Promise.resolve();
11198
11221
  }
11199
11222
  (_this$_abortControlle = this._abortController) === null || _this$_abortControlle === void 0 ? void 0 : (_this$_abortControlle2 = _this$_abortControlle.abort) === null || _this$_abortControlle2 === void 0 ? void 0 : _this$_abortControlle2.call(_this$_abortControlle);
11223
+ this.isPossibleToPublish = false;
11200
11224
  this.isDisconnecting = true;
11201
11225
  this._stopKeepAlive();
11202
11226
  this._disableStatsWatch();
@@ -11317,6 +11341,7 @@ class RoomSession {
11317
11341
  (_this$_abortControlle3 = this._abortController) === null || _this$_abortControlle3 === void 0 ? void 0 : (_this$_abortControlle4 = _this$_abortControlle3.abort) === null || _this$_abortControlle4 === void 0 ? void 0 : _this$_abortControlle4.call(_this$_abortControlle3);
11318
11342
  this._stopKeepAlive();
11319
11343
  let isStreaming = this.isStreaming;
11344
+ this.isPossibleToPublish = false;
11320
11345
  this.isDisconnecting = true;
11321
11346
  return this._removeParticipant(this.handleId).finally(() => {
11322
11347
  this.sendMessage(this.handleId, {
@@ -12372,7 +12397,7 @@ class RoomSession {
12372
12397
  var _stream$getVideoTrack, _stream$getAudioTrack, _config$stream4, _config$stream4$getAu, _config$stream5, _config$stream5$getVi, _stream$getAudioTrack2, _stream$getVideoTrack2;
12373
12398
  let stream = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
12374
12399
  let source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'camera0';
12375
- if (this.isDisconnecting || !this.isConnected) {
12400
+ if (!this.isPossibleToPublish) {
12376
12401
  return Promise.reject({
12377
12402
  type: 'warning',
12378
12403
  id: 18,