@reactoo/watchtogether-sdk-js 2.7.92-beta.0 → 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.
package/package.json
CHANGED
package/src/modules/wt-room.js
CHANGED
|
@@ -259,6 +259,7 @@ class RoomSession {
|
|
|
259
259
|
this.isConnecting = false;
|
|
260
260
|
this.isDisconnecting = false;
|
|
261
261
|
this.isConnected = false;
|
|
262
|
+
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
|
|
262
263
|
this.isPublished = false;
|
|
263
264
|
this.isStreaming = false;
|
|
264
265
|
this.isMuted = [];
|
|
@@ -563,7 +564,6 @@ class RoomSession {
|
|
|
563
564
|
this.ws.removeEventListener('message', parseResponse);
|
|
564
565
|
if (json['janus'] === 'error') {
|
|
565
566
|
if (json?.error?.code == 403) {
|
|
566
|
-
console.log(1);
|
|
567
567
|
this.disconnect(true);
|
|
568
568
|
}
|
|
569
569
|
reject({type: 'error', id: 2, message: 'send failed', data: json, requestData});
|
|
@@ -643,7 +643,6 @@ class RoomSession {
|
|
|
643
643
|
this._retries++;
|
|
644
644
|
if(this._retries > this._maxRetries) {
|
|
645
645
|
if (this.sessiontype === 'reactooroom') {
|
|
646
|
-
console.log(2);
|
|
647
646
|
this.disconnect(true);
|
|
648
647
|
} else if (this.sessiontype === 'streaming') {
|
|
649
648
|
this.stopStream();
|
|
@@ -671,7 +670,6 @@ class RoomSession {
|
|
|
671
670
|
}, 3000 * this._retries);
|
|
672
671
|
} else {
|
|
673
672
|
if (this.sessiontype === 'reactooroom') {
|
|
674
|
-
console.log(3);
|
|
675
673
|
this.disconnect(true);
|
|
676
674
|
} else if (this.sessiontype === 'streaming') {
|
|
677
675
|
this.stopStream();
|
|
@@ -808,6 +806,7 @@ class RoomSession {
|
|
|
808
806
|
this.id = msg["id"];
|
|
809
807
|
this.privateId = msg["private_id"];
|
|
810
808
|
this.isConnected = true;
|
|
809
|
+
this.isPossibleToPublish = true;
|
|
811
810
|
this._log('We have successfully joined Room');
|
|
812
811
|
this.emit('joined', true, this.constructId);
|
|
813
812
|
this.emit('addLocalParticipant', {
|
|
@@ -947,7 +946,6 @@ class RoomSession {
|
|
|
947
946
|
this._removeParticipant(this.handleId);
|
|
948
947
|
if (msg['reason'] === 'kicked') {
|
|
949
948
|
this.emit('kicked');
|
|
950
|
-
console.log(4);
|
|
951
949
|
this.disconnect().catch(() => {});
|
|
952
950
|
}
|
|
953
951
|
} else if (leaving) {
|
|
@@ -1442,6 +1440,7 @@ class RoomSession {
|
|
|
1442
1440
|
? this.sendMessage(this.handleId, {body: {"request": "leave"}}, dontWait)
|
|
1443
1441
|
.finally(() => {
|
|
1444
1442
|
this.isConnected = false;
|
|
1443
|
+
this.isPossibleToPublish = false;
|
|
1445
1444
|
this.emit('joined', false);
|
|
1446
1445
|
})
|
|
1447
1446
|
: Promise.resolve();
|
|
@@ -1452,7 +1451,7 @@ class RoomSession {
|
|
|
1452
1451
|
if (this.isConnecting) {
|
|
1453
1452
|
return Promise.reject({type: 'warning', id: 16, message: 'connection establishment already in progress'});
|
|
1454
1453
|
}
|
|
1455
|
-
|
|
1454
|
+
this.isPossibleToPublish = false;
|
|
1456
1455
|
this.isConnecting = true;
|
|
1457
1456
|
this.emit('joining', true);
|
|
1458
1457
|
|
|
@@ -1506,6 +1505,7 @@ class RoomSession {
|
|
|
1506
1505
|
this._enableStatsWatch();
|
|
1507
1506
|
this._enableSubstreamAutoSelect();
|
|
1508
1507
|
this.isConnecting = false;
|
|
1508
|
+
this.isPossibleToPublish = true;
|
|
1509
1509
|
this.emit('joining', false);
|
|
1510
1510
|
resolve(this);
|
|
1511
1511
|
})
|
|
@@ -1549,6 +1549,22 @@ class RoomSession {
|
|
|
1549
1549
|
}
|
|
1550
1550
|
|
|
1551
1551
|
_httpConnection(reclaim = false) {
|
|
1552
|
+
|
|
1553
|
+
if (this.isConnecting) {
|
|
1554
|
+
return Promise.reject({type: 'warning', id: 16, message: 'connection establishment already in progress'});
|
|
1555
|
+
}
|
|
1556
|
+
this.isPossibleToPublish = false;
|
|
1557
|
+
this.isConnecting = true;
|
|
1558
|
+
this.emit('joining', true);
|
|
1559
|
+
|
|
1560
|
+
if (this.ws) {
|
|
1561
|
+
this._wipeListeners();
|
|
1562
|
+
if (this.ws.readyState === 1) {
|
|
1563
|
+
this.ws.close();
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
this._stopKeepAlive();
|
|
1567
|
+
|
|
1552
1568
|
if(!reclaim) {
|
|
1553
1569
|
return this._send({"janus": "create"})
|
|
1554
1570
|
.then(json => {
|
|
@@ -1568,6 +1584,7 @@ class RoomSession {
|
|
|
1568
1584
|
this._enableSubstreamAutoSelect();
|
|
1569
1585
|
this._longPoll();
|
|
1570
1586
|
this.isConnecting = false;
|
|
1587
|
+
this.isPossibleToPublish = true;
|
|
1571
1588
|
this.emit('joining', false);
|
|
1572
1589
|
return Promise.resolve(this);
|
|
1573
1590
|
})
|
|
@@ -1676,6 +1693,7 @@ class RoomSession {
|
|
|
1676
1693
|
}
|
|
1677
1694
|
|
|
1678
1695
|
this._abortController?.abort?.();
|
|
1696
|
+
this.isPossibleToPublish = false;
|
|
1679
1697
|
this.isDisconnecting = true;
|
|
1680
1698
|
this._stopKeepAlive();
|
|
1681
1699
|
this._disableStatsWatch();
|
|
@@ -1789,6 +1807,7 @@ class RoomSession {
|
|
|
1789
1807
|
this._stopKeepAlive();
|
|
1790
1808
|
|
|
1791
1809
|
let isStreaming = this.isStreaming;
|
|
1810
|
+
this.isPossibleToPublish = false;
|
|
1792
1811
|
this.isDisconnecting = true;
|
|
1793
1812
|
return this._removeParticipant(this.handleId)
|
|
1794
1813
|
.finally(() => {
|
|
@@ -1811,7 +1830,6 @@ class RoomSession {
|
|
|
1811
1830
|
destroy() {
|
|
1812
1831
|
|
|
1813
1832
|
if (this.sessiontype === 'reactooroom') {
|
|
1814
|
-
console.log(5);
|
|
1815
1833
|
return this.disconnect()
|
|
1816
1834
|
.then(() => {
|
|
1817
1835
|
this.clear();
|
|
@@ -2916,9 +2934,7 @@ class RoomSession {
|
|
|
2916
2934
|
|
|
2917
2935
|
publishLocal(stream = null, source = 'camera0') {
|
|
2918
2936
|
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
if(this.isDisconnecting || !this.isConnected) {
|
|
2937
|
+
if(!this.isPossibleToPublish) {
|
|
2922
2938
|
return Promise.reject({
|
|
2923
2939
|
type: 'warning',
|
|
2924
2940
|
id: 18,
|