@reactoo/watchtogether-sdk-js 2.8.52 → 2.8.53
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
|
@@ -61,6 +61,10 @@ let roomSession = function ({roomId, pinHash, role, options = {}}, room, wt) {
|
|
|
61
61
|
___.__parseDataMessageEvents(data);
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
+
room.on('restartConnection', () => {
|
|
65
|
+
___.restart();
|
|
66
|
+
})
|
|
67
|
+
|
|
64
68
|
room.on('error', (e) => {
|
|
65
69
|
if(e?.type === 'error') {
|
|
66
70
|
___.disconnect();
|
|
@@ -161,6 +165,10 @@ let roomSession = function ({roomId, pinHash, role, options = {}}, room, wt) {
|
|
|
161
165
|
//TODO: refactor restart method
|
|
162
166
|
restart: function ({isObserver = false, reactooRoomId = null} = {}) {
|
|
163
167
|
|
|
168
|
+
if(room.isRestarting) {
|
|
169
|
+
return Promise.resolve(0);
|
|
170
|
+
}
|
|
171
|
+
|
|
164
172
|
emitter.emit('reconnecting', true);
|
|
165
173
|
room.isRestarting = true;
|
|
166
174
|
|
|
@@ -192,7 +200,7 @@ let roomSession = function ({roomId, pinHash, role, options = {}}, room, wt) {
|
|
|
192
200
|
.catch((error) => {
|
|
193
201
|
room.isRestarting = false;
|
|
194
202
|
emitter.emit('reconnecting', false);
|
|
195
|
-
emitter.emit('error', {type: 'error', id:
|
|
203
|
+
emitter.emit('error', {type: 'error', id: 53, message: 'reconnecting failed', data: error});
|
|
196
204
|
return Promise.reject(0);
|
|
197
205
|
});
|
|
198
206
|
|
package/src/modules/wt-iot2.js
CHANGED
|
@@ -280,6 +280,7 @@ class Iot {
|
|
|
280
280
|
event === 'record_stop' ||
|
|
281
281
|
event === 'record_configured' ||
|
|
282
282
|
event === 'record_livestream_available' ||
|
|
283
|
+
event === 'record_livestream_viewercount' ||
|
|
283
284
|
event === 'record_livestream_kick' ||
|
|
284
285
|
event === 'user_update_displayname' ||
|
|
285
286
|
event === 'user_update_avatar' ||
|
|
@@ -1014,7 +1014,9 @@ class RoomSession {
|
|
|
1014
1014
|
.catch(e => {
|
|
1015
1015
|
|
|
1016
1016
|
if(e?.code === 403) {
|
|
1017
|
-
this.
|
|
1017
|
+
if(!this.isDisconnecting) {
|
|
1018
|
+
this.disconnect().catch(()=>{});
|
|
1019
|
+
}
|
|
1018
1020
|
}
|
|
1019
1021
|
|
|
1020
1022
|
return Promise.reject({error: e, requestData});
|
|
@@ -1064,7 +1066,9 @@ class RoomSession {
|
|
|
1064
1066
|
cleanup();
|
|
1065
1067
|
if (json['janus'] === 'error') {
|
|
1066
1068
|
if (json?.error?.code == 403) {
|
|
1067
|
-
this.
|
|
1069
|
+
if(!this.isDisconnecting) {
|
|
1070
|
+
this.disconnect().catch(()=>{});
|
|
1071
|
+
}
|
|
1068
1072
|
}
|
|
1069
1073
|
reject({type: 'error', id: 5, message: 'send failed', data: json, requestData});
|
|
1070
1074
|
} else {
|
|
@@ -1202,7 +1206,19 @@ class RoomSession {
|
|
|
1202
1206
|
this.#reconnect()
|
|
1203
1207
|
.catch(e => {
|
|
1204
1208
|
if(e.type !== 'warning') {
|
|
1205
|
-
|
|
1209
|
+
|
|
1210
|
+
if(this.isSupposeToBeConnected) {
|
|
1211
|
+
this.emit('restartConnection');
|
|
1212
|
+
wait(10000).then(() => {
|
|
1213
|
+
if(!this.isConnected && !this.isRestarting && this.isSupposeToBeConnected) {
|
|
1214
|
+
this.disconnect().catch(()=>{});
|
|
1215
|
+
this.emit('error', {type: 'error', id: 52, message: 'Could not re-establish connection, disconnecting' , originalError: e});
|
|
1216
|
+
}
|
|
1217
|
+
})
|
|
1218
|
+
}
|
|
1219
|
+
else if(!this.isDisconnecting) {
|
|
1220
|
+
this.disconnect().catch(()=>{});
|
|
1221
|
+
}
|
|
1206
1222
|
}
|
|
1207
1223
|
this.emit('error', e)
|
|
1208
1224
|
});
|
|
@@ -1300,7 +1316,7 @@ class RoomSession {
|
|
|
1300
1316
|
} else if (type === "hangup") {
|
|
1301
1317
|
this._log('hangup on', handle.handleId, handle.handleId === this.handleId, json);
|
|
1302
1318
|
if(this.#getHandle(handle.handleId)) {
|
|
1303
|
-
this.#cleanupHandle(handle.handleId,
|
|
1319
|
+
this.#cleanupHandle(handle.handleId, false).catch(() => {});
|
|
1304
1320
|
}
|
|
1305
1321
|
} else if (type === "detached") {
|
|
1306
1322
|
this._log('detached on', handle.handleId, handle.handleId === this.handleId, json);
|
|
@@ -1402,7 +1418,9 @@ class RoomSession {
|
|
|
1402
1418
|
|
|
1403
1419
|
if (msg['reason'] === 'kicked') {
|
|
1404
1420
|
this.emit('kicked');
|
|
1405
|
-
this.
|
|
1421
|
+
if(!this.isDisconnecting) {
|
|
1422
|
+
this.disconnect().catch(()=>{});
|
|
1423
|
+
}
|
|
1406
1424
|
}
|
|
1407
1425
|
} else if (leaving) {
|
|
1408
1426
|
|
|
@@ -1418,7 +1436,7 @@ class RoomSession {
|
|
|
1418
1436
|
|
|
1419
1437
|
if (unpublished === 'ok') {
|
|
1420
1438
|
this._log('unpublished', this.#publisherHandle?.handleId, 'this is us');
|
|
1421
|
-
this.#cleanupHandle(this.#publisherHandle?.handleId,
|
|
1439
|
+
this.#cleanupHandle(this.#publisherHandle?.handleId, false).catch(() => {});
|
|
1422
1440
|
|
|
1423
1441
|
} else if (unpublished) {
|
|
1424
1442
|
this._log('unpublished', unpublished);
|
|
@@ -1736,6 +1754,9 @@ class RoomSession {
|
|
|
1736
1754
|
|
|
1737
1755
|
if(this.#publisherHandle && handleId === this.#publisherHandle?.handleId) {
|
|
1738
1756
|
this.#emitLocalFeedUpdate({feedRemoval: true});
|
|
1757
|
+
this.isPublished = false;
|
|
1758
|
+
this.emit('publishing', false);
|
|
1759
|
+
this.emit('published', false);
|
|
1739
1760
|
}
|
|
1740
1761
|
else if(this.#subscriberHandle && handleId === this.#subscriberHandle.handleId) {
|
|
1741
1762
|
[...this.#getCachedAttendeeIds()].forEach(id => {
|
|
@@ -1832,6 +1853,8 @@ class RoomSession {
|
|
|
1832
1853
|
return this.#subscriberJoinPromise;
|
|
1833
1854
|
}
|
|
1834
1855
|
|
|
1856
|
+
// not used
|
|
1857
|
+
|
|
1835
1858
|
async #leaveRoom(dontWait = false) {
|
|
1836
1859
|
return this.isConnected
|
|
1837
1860
|
? this.sendMessage(this.#publisherHandle?.handleId, {body: {"request": "leave"}}, dontWait)
|
|
@@ -2110,7 +2133,9 @@ class RoomSession {
|
|
|
2110
2133
|
|
|
2111
2134
|
} catch (error) {
|
|
2112
2135
|
if(error?.type !== 'warning') {
|
|
2113
|
-
this.
|
|
2136
|
+
if(!this.isDisconnecting) {
|
|
2137
|
+
this.disconnect().catch(()=>{});
|
|
2138
|
+
}
|
|
2114
2139
|
}
|
|
2115
2140
|
this.emit('error', error);
|
|
2116
2141
|
} finally {
|
|
@@ -2134,7 +2159,6 @@ class RoomSession {
|
|
|
2134
2159
|
this._abortController?.abort?.();
|
|
2135
2160
|
this.isDisconnecting = true;
|
|
2136
2161
|
this.#stopKeepAlive();
|
|
2137
|
-
let isConnected = this.isConnected;
|
|
2138
2162
|
|
|
2139
2163
|
if(this.#publisherHandle) {
|
|
2140
2164
|
this.#emitLocalFeedUpdate({feedRemoval: true});
|
|
@@ -2194,12 +2218,10 @@ class RoomSession {
|
|
|
2194
2218
|
this.display = null;
|
|
2195
2219
|
this.userId = null;
|
|
2196
2220
|
|
|
2197
|
-
|
|
2221
|
+
const isConnected = this.isConnected;
|
|
2198
2222
|
this.isConnecting = false;
|
|
2199
2223
|
this.isConnected = false;
|
|
2200
2224
|
this.isDisconnecting = false;
|
|
2201
|
-
this.emit('publishing', false);
|
|
2202
|
-
this.emit('published', false);
|
|
2203
2225
|
this.emit('joining', false);
|
|
2204
2226
|
this.emit('joined', false);
|
|
2205
2227
|
this.emit('disconnect', isConnected);
|
|
@@ -2633,8 +2655,8 @@ class RoomSession {
|
|
|
2633
2655
|
|
|
2634
2656
|
if (this.handleId === handleId) {
|
|
2635
2657
|
this._log('Performing local ICE restart');
|
|
2636
|
-
|
|
2637
|
-
|
|
2658
|
+
const hasAudio = !!(config.stream && config.stream.getAudioTracks().length > 0);
|
|
2659
|
+
const hasVideo = !!(config.stream && config.stream.getVideoTracks().length > 0);
|
|
2638
2660
|
this.#createAO('offer', handleId, true )
|
|
2639
2661
|
.then((jsep) => {
|
|
2640
2662
|
if (!jsep) {
|
|
@@ -2651,7 +2673,21 @@ class RoomSession {
|
|
|
2651
2673
|
})
|
|
2652
2674
|
.catch((e) => {
|
|
2653
2675
|
config.isIceRestarting = false;
|
|
2654
|
-
|
|
2676
|
+
|
|
2677
|
+
if(this.isSupposeToBeConnected) {
|
|
2678
|
+
this.emit('restartConnection');
|
|
2679
|
+
wait(10000).then(() => {
|
|
2680
|
+
if(!this.isConnected && !this.isRestarting && this.isSupposeToBeConnected) {
|
|
2681
|
+
this.disconnect().catch(()=>{});
|
|
2682
|
+
this.emit('error', {type: 'error', id: 28,message: 'Could not re-establish connection, disconnecting', originalError: e});
|
|
2683
|
+
}
|
|
2684
|
+
})
|
|
2685
|
+
}
|
|
2686
|
+
else if(!this.isDisconnecting) {
|
|
2687
|
+
this.disconnect().catch(()=>{});
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
|
|
2655
2691
|
});
|
|
2656
2692
|
} else {
|
|
2657
2693
|
this._log('Performing remote ICE restart', handleId);
|