@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.
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 = [];
|
|
@@ -805,6 +806,7 @@ class RoomSession {
|
|
|
805
806
|
this.id = msg["id"];
|
|
806
807
|
this.privateId = msg["private_id"];
|
|
807
808
|
this.isConnected = true;
|
|
809
|
+
this.isPossibleToPublish = true;
|
|
808
810
|
this._log('We have successfully joined Room');
|
|
809
811
|
this.emit('joined', true, this.constructId);
|
|
810
812
|
this.emit('addLocalParticipant', {
|
|
@@ -1438,6 +1440,7 @@ class RoomSession {
|
|
|
1438
1440
|
? this.sendMessage(this.handleId, {body: {"request": "leave"}}, dontWait)
|
|
1439
1441
|
.finally(() => {
|
|
1440
1442
|
this.isConnected = false;
|
|
1443
|
+
this.isPossibleToPublish = false;
|
|
1441
1444
|
this.emit('joined', false);
|
|
1442
1445
|
})
|
|
1443
1446
|
: Promise.resolve();
|
|
@@ -1448,7 +1451,7 @@ class RoomSession {
|
|
|
1448
1451
|
if (this.isConnecting) {
|
|
1449
1452
|
return Promise.reject({type: 'warning', id: 16, message: 'connection establishment already in progress'});
|
|
1450
1453
|
}
|
|
1451
|
-
|
|
1454
|
+
this.isPossibleToPublish = false;
|
|
1452
1455
|
this.isConnecting = true;
|
|
1453
1456
|
this.emit('joining', true);
|
|
1454
1457
|
|
|
@@ -1502,6 +1505,7 @@ class RoomSession {
|
|
|
1502
1505
|
this._enableStatsWatch();
|
|
1503
1506
|
this._enableSubstreamAutoSelect();
|
|
1504
1507
|
this.isConnecting = false;
|
|
1508
|
+
this.isPossibleToPublish = true;
|
|
1505
1509
|
this.emit('joining', false);
|
|
1506
1510
|
resolve(this);
|
|
1507
1511
|
})
|
|
@@ -1545,6 +1549,22 @@ class RoomSession {
|
|
|
1545
1549
|
}
|
|
1546
1550
|
|
|
1547
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
|
+
|
|
1548
1568
|
if(!reclaim) {
|
|
1549
1569
|
return this._send({"janus": "create"})
|
|
1550
1570
|
.then(json => {
|
|
@@ -1564,6 +1584,7 @@ class RoomSession {
|
|
|
1564
1584
|
this._enableSubstreamAutoSelect();
|
|
1565
1585
|
this._longPoll();
|
|
1566
1586
|
this.isConnecting = false;
|
|
1587
|
+
this.isPossibleToPublish = true;
|
|
1567
1588
|
this.emit('joining', false);
|
|
1568
1589
|
return Promise.resolve(this);
|
|
1569
1590
|
})
|
|
@@ -1672,6 +1693,7 @@ class RoomSession {
|
|
|
1672
1693
|
}
|
|
1673
1694
|
|
|
1674
1695
|
this._abortController?.abort?.();
|
|
1696
|
+
this.isPossibleToPublish = false;
|
|
1675
1697
|
this.isDisconnecting = true;
|
|
1676
1698
|
this._stopKeepAlive();
|
|
1677
1699
|
this._disableStatsWatch();
|
|
@@ -1785,6 +1807,7 @@ class RoomSession {
|
|
|
1785
1807
|
this._stopKeepAlive();
|
|
1786
1808
|
|
|
1787
1809
|
let isStreaming = this.isStreaming;
|
|
1810
|
+
this.isPossibleToPublish = false;
|
|
1788
1811
|
this.isDisconnecting = true;
|
|
1789
1812
|
return this._removeParticipant(this.handleId)
|
|
1790
1813
|
.finally(() => {
|
|
@@ -2911,7 +2934,7 @@ class RoomSession {
|
|
|
2911
2934
|
|
|
2912
2935
|
publishLocal(stream = null, source = 'camera0') {
|
|
2913
2936
|
|
|
2914
|
-
if(
|
|
2937
|
+
if(!this.isPossibleToPublish) {
|
|
2915
2938
|
return Promise.reject({
|
|
2916
2939
|
type: 'warning',
|
|
2917
2940
|
id: 18,
|