@reactoo/watchtogether-sdk-js 2.7.92-beta.0 → 2.7.92

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.
@@ -9869,11 +9869,19 @@ class RoomSession {
9869
9869
  this.apisecret = null;
9870
9870
  this.handleId = null;
9871
9871
  this.ws = null;
9872
+
9873
+ // helper flags
9874
+
9872
9875
  this.isSupposeToBeConnected = false;
9873
9876
  this.isRestarting = false;
9874
9877
  this.isConnecting = false;
9875
9878
  this.isDisconnecting = false;
9876
9879
  this.isConnected = false;
9880
+
9881
+ // we added this because joined event that enables "isConnected" happened after we fired publish (long polling)
9882
+ // as a result publish was rejected due to isConnected flag being false
9883
+ // im' not sure what relies on current event based isConnected flag so i've added a new one that is set after join promise resolves
9884
+ this.isPossibleToPublish = false;
9877
9885
  this.isPublished = false;
9878
9886
  this.isStreaming = false;
9879
9887
  this.isMuted = [];
@@ -10121,7 +10129,6 @@ class RoomSession {
10121
10129
  if (json['janus'] === 'error') {
10122
10130
  var _json$error;
10123
10131
  if ((json === null || json === void 0 ? void 0 : (_json$error = json.error) === null || _json$error === void 0 ? void 0 : _json$error.code) == 403) {
10124
- console.log(1);
10125
10132
  this.disconnect(true);
10126
10133
  }
10127
10134
  reject({
@@ -10204,7 +10211,6 @@ class RoomSession {
10204
10211
  this._retries++;
10205
10212
  if (this._retries > this._maxRetries) {
10206
10213
  if (this.sessiontype === 'reactooroom') {
10207
- console.log(2);
10208
10214
  this.disconnect(true);
10209
10215
  } else if (this.sessiontype === 'streaming') {
10210
10216
  this.stopStream();
@@ -10233,7 +10239,6 @@ class RoomSession {
10233
10239
  }, 3000 * this._retries);
10234
10240
  } else {
10235
10241
  if (this.sessiontype === 'reactooroom') {
10236
- console.log(3);
10237
10242
  this.disconnect(true);
10238
10243
  } else if (this.sessiontype === 'streaming') {
10239
10244
  this.stopStream();
@@ -10366,6 +10371,7 @@ class RoomSession {
10366
10371
  this.id = msg["id"];
10367
10372
  this.privateId = msg["private_id"];
10368
10373
  this.isConnected = true;
10374
+ this.isPossibleToPublish = true;
10369
10375
  this._log('We have successfully joined Room');
10370
10376
  this.emit('joined', true, this.constructId);
10371
10377
  this.emit('addLocalParticipant', {
@@ -10501,7 +10507,6 @@ class RoomSession {
10501
10507
  this._removeParticipant(this.handleId);
10502
10508
  if (msg['reason'] === 'kicked') {
10503
10509
  this.emit('kicked');
10504
- console.log(4);
10505
10510
  this.disconnect().catch(() => {});
10506
10511
  }
10507
10512
  } else if (leaving) {
@@ -10977,6 +10982,7 @@ class RoomSession {
10977
10982
  }
10978
10983
  }, dontWait).finally(() => {
10979
10984
  this.isConnected = false;
10985
+ this.isPossibleToPublish = false;
10980
10986
  this.emit('joined', false);
10981
10987
  }) : Promise.resolve();
10982
10988
  }
@@ -10989,6 +10995,7 @@ class RoomSession {
10989
10995
  message: 'connection establishment already in progress'
10990
10996
  });
10991
10997
  }
10998
+ this.isPossibleToPublish = false;
10992
10999
  this.isConnecting = true;
10993
11000
  this.emit('joining', true);
10994
11001
  if (this.ws) {
@@ -11035,6 +11042,7 @@ class RoomSession {
11035
11042
  this._enableStatsWatch();
11036
11043
  this._enableSubstreamAutoSelect();
11037
11044
  this.isConnecting = false;
11045
+ this.isPossibleToPublish = true;
11038
11046
  this.emit('joining', false);
11039
11047
  resolve(this);
11040
11048
  }).catch(error => {
@@ -11085,6 +11093,23 @@ class RoomSession {
11085
11093
  }
11086
11094
  _httpConnection() {
11087
11095
  let reclaim = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11096
+ if (this.isConnecting) {
11097
+ return Promise.reject({
11098
+ type: 'warning',
11099
+ id: 16,
11100
+ message: 'connection establishment already in progress'
11101
+ });
11102
+ }
11103
+ this.isPossibleToPublish = false;
11104
+ this.isConnecting = true;
11105
+ this.emit('joining', true);
11106
+ if (this.ws) {
11107
+ this._wipeListeners();
11108
+ if (this.ws.readyState === 1) {
11109
+ this.ws.close();
11110
+ }
11111
+ }
11112
+ this._stopKeepAlive();
11088
11113
  if (!reclaim) {
11089
11114
  return this._send({
11090
11115
  "janus": "create"
@@ -11101,6 +11126,7 @@ class RoomSession {
11101
11126
  this._enableSubstreamAutoSelect();
11102
11127
  this._longPoll();
11103
11128
  this.isConnecting = false;
11129
+ this.isPossibleToPublish = true;
11104
11130
  this.emit('joining', false);
11105
11131
  return Promise.resolve(this);
11106
11132
  }).catch(error => {
@@ -11201,6 +11227,7 @@ class RoomSession {
11201
11227
  return Promise.resolve();
11202
11228
  }
11203
11229
  (_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);
11230
+ this.isPossibleToPublish = false;
11204
11231
  this.isDisconnecting = true;
11205
11232
  this._stopKeepAlive();
11206
11233
  this._disableStatsWatch();
@@ -11321,6 +11348,7 @@ class RoomSession {
11321
11348
  (_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);
11322
11349
  this._stopKeepAlive();
11323
11350
  let isStreaming = this.isStreaming;
11351
+ this.isPossibleToPublish = false;
11324
11352
  this.isDisconnecting = true;
11325
11353
  return this._removeParticipant(this.handleId).finally(() => {
11326
11354
  this.sendMessage(this.handleId, {
@@ -11346,7 +11374,6 @@ class RoomSession {
11346
11374
  }
11347
11375
  destroy() {
11348
11376
  if (this.sessiontype === 'reactooroom') {
11349
- console.log(5);
11350
11377
  return this.disconnect().then(() => {
11351
11378
  this.clear();
11352
11379
  return true;
@@ -12377,8 +12404,7 @@ class RoomSession {
12377
12404
  var _stream$getVideoTrack, _stream$getAudioTrack, _config$stream4, _config$stream4$getAu, _config$stream5, _config$stream5$getVi, _stream$getAudioTrack2, _stream$getVideoTrack2;
12378
12405
  let stream = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
12379
12406
  let source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'camera0';
12380
- console.log(this.isDisconnecting, this.isConnected);
12381
- if (this.isDisconnecting || !this.isConnected) {
12407
+ if (!this.isPossibleToPublish) {
12382
12408
  return Promise.reject({
12383
12409
  type: 'warning',
12384
12410
  id: 18,