@reactoo/watchtogether-sdk-js 2.5.23 → 2.5.30
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/dist/watchtogether-sdk.js +1013 -202
- package/dist/watchtogether-sdk.min.js +2 -2
- package/example/bulk_join_room/bulk_join_room.html +31 -2
- package/package.json +1 -1
- package/src/models/room-session.js +3 -9
- package/src/modules/sync-modules/sync-dash-vod.js +1 -1
- package/src/modules/sync-modules/sync-dash.js +1 -1
- package/src/modules/sync-modules/sync-dazn-dash.js +1 -1
- package/src/modules/sync-modules/sync-doris.js +1 -1
- package/src/modules/sync-modules/sync-hls-vod.js +1 -1
- package/src/modules/sync-modules/sync-hls.js +1 -1
- package/src/modules/sync-modules/sync-native-hls-vod.js +1 -1
- package/src/modules/sync-modules/sync-native-hls.js +1 -1
- package/src/modules/sync-modules/sync-shaka-dash-vod.js +1 -1
- package/src/modules/sync-modules/sync-shaka-dash.js +1 -1
- package/src/modules/sync-modules/sync-universal.js +1 -1
- package/src/modules/wt-room.js +16 -12
|
@@ -19,7 +19,12 @@
|
|
|
19
19
|
<!--<br><br>-->
|
|
20
20
|
|
|
21
21
|
<label for="room-id">Room ID</label><br>
|
|
22
|
-
<input type="text" id="room-id" placeholder="
|
|
22
|
+
<input type="text" id="room-id" placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" size="40">
|
|
23
|
+
|
|
24
|
+
<br><br>
|
|
25
|
+
|
|
26
|
+
<label for="pin-hash">Pin Hash</label><br>
|
|
27
|
+
<input type="text" id="pin-hash" placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" size="40">
|
|
23
28
|
|
|
24
29
|
<br><br>
|
|
25
30
|
|
|
@@ -48,6 +53,7 @@
|
|
|
48
53
|
let participantsCount = 3;
|
|
49
54
|
let instanceType = "reactooDemo";
|
|
50
55
|
let roomId = "0512f218-6a4a-45e1-9d05-d5a0e5afb33d";
|
|
56
|
+
let pinHash = undefined;
|
|
51
57
|
let timeoutBetweenParticipantsJoins = 5000;
|
|
52
58
|
|
|
53
59
|
let participantsData = null;
|
|
@@ -65,8 +71,17 @@
|
|
|
65
71
|
participantsCount = parseInt(document.getElementById('users-count').value);
|
|
66
72
|
// instanceType = document.getElementById('instance-type').value;
|
|
67
73
|
roomId = document.getElementById('room-id').value;
|
|
74
|
+
pinHash = document.getElementById('pin-hash').value;
|
|
68
75
|
timeoutBetweenParticipantsJoins = document.getElementById('connection-timeout').value;
|
|
69
76
|
|
|
77
|
+
const url = new URL(location.href);
|
|
78
|
+
participantsCount ? url.searchParams.set('participantsCount', participantsCount) : url.searchParams.delete('participantsCount');
|
|
79
|
+
// instanceType ? url.searchParams.set('instanceType', instanceType) : url.searchParams.delete('instanceType');
|
|
80
|
+
roomId ? url.searchParams.set('roomId', roomId) : url.searchParams.delete('roomId');
|
|
81
|
+
pinHash ? url.searchParams.set('pinHash', pinHash) : url.searchParams.delete('pinHash');
|
|
82
|
+
timeoutBetweenParticipantsJoins ? url.searchParams.set('timeoutBetweenParticipantsJoins', timeoutBetweenParticipantsJoins) : url.searchParams.delete('timeoutBetweenParticipantsJoins');
|
|
83
|
+
history.replaceState (null, '', url);
|
|
84
|
+
|
|
70
85
|
document.getElementById('join-room').setAttribute('disabled', true);
|
|
71
86
|
document.getElementById('joined-participants-count').value = joinedParticipantsCount;
|
|
72
87
|
|
|
@@ -169,7 +184,7 @@
|
|
|
169
184
|
|
|
170
185
|
function joinRoom(participantData) {
|
|
171
186
|
return participantData.sdkInstance.auth.deviceLogin(participantData.id)
|
|
172
|
-
.then(() => participantData.sdkInstance.room.createSession({roomId}))
|
|
187
|
+
.then(() => participantData.sdkInstance.room.createSession({roomId, pinHash}))
|
|
173
188
|
.then(session => {
|
|
174
189
|
participantData.session = session;
|
|
175
190
|
return Promise.all([session, session.connect()])
|
|
@@ -182,10 +197,24 @@
|
|
|
182
197
|
return participantData.session.disconnect();
|
|
183
198
|
}
|
|
184
199
|
|
|
200
|
+
function getQueryVar(varName){
|
|
201
|
+
const queryStr = decodeURI(window.location.search) + '&';
|
|
202
|
+
const regex = new RegExp('.*?[&\\?]' + varName + '=(.*?)&.*');
|
|
203
|
+
const val = queryStr.replace(regex, "$1");
|
|
204
|
+
return val === queryStr ? false : val;
|
|
205
|
+
}
|
|
206
|
+
|
|
185
207
|
document.addEventListener("DOMContentLoaded", function() {
|
|
208
|
+
participantsCount = getQueryVar('participantsCount') || participantsCount;
|
|
209
|
+
// instanceType = getQueryVar('instanceType') || instanceType;
|
|
210
|
+
roomId = getQueryVar('roomId') || roomId;
|
|
211
|
+
pinHash = getQueryVar('pinHash') || pinHash || '';
|
|
212
|
+
timeoutBetweenParticipantsJoins = getQueryVar('timeoutBetweenParticipantsJoins') || timeoutBetweenParticipantsJoins;
|
|
213
|
+
|
|
186
214
|
document.getElementById('users-count').value = participantsCount;
|
|
187
215
|
// document.getElementById('instance-type').value = instanceType;
|
|
188
216
|
document.getElementById('room-id').value = roomId;
|
|
217
|
+
document.getElementById('pin-hash').value = pinHash;
|
|
189
218
|
document.getElementById('connection-timeout').value = timeoutBetweenParticipantsJoins;
|
|
190
219
|
});
|
|
191
220
|
|
package/package.json
CHANGED
|
@@ -102,7 +102,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
102
102
|
return Promise.all([roomData, userData])
|
|
103
103
|
})
|
|
104
104
|
.then(([roomData, userData]) => Promise.all([roomData, userData, this.setRoomVars()]))
|
|
105
|
-
.then(([roomData, userData, _]) => Promise.all([roomData, userData, room.connect(roomData.data.roomId, roomData.data.pin, roomData.data.href, roomData.data.iceServers, roomData.data.accessToken,
|
|
105
|
+
.then(([roomData, userData, _]) => Promise.all([roomData, userData, room.connect(roomData.data.roomId, roomData.data.pin, roomData.data.href, roomData.data.iceServers, roomData.data.accessToken, roomData.data.display, roomData.data.userId, roomData.data.webrtcVersion, (roomData.data.bitrate ? parseInt(roomData.data.bitrate) : 0), isMonitor, roomData.data.recordingFilename)]))
|
|
106
106
|
.finally(() => {
|
|
107
107
|
emitter.emit('connecting', false);
|
|
108
108
|
})
|
|
@@ -170,7 +170,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
170
170
|
} else if (msg.action === 'user_update_displayname' || msg.action === 'user_update_avatar' || msg.action === 'user_update_customattributes' || msg.action === 'user_update_privateattributes') {
|
|
171
171
|
emitter.emit('userUpdate', msg.text);
|
|
172
172
|
} else if (msg.action === 'observer_connecting' || msg.action === 'talkback_connecting' || msg.action === 'instructor_connecting') {
|
|
173
|
-
this.setRoomVars(
|
|
173
|
+
this.setRoomVars().catch(e => {
|
|
174
174
|
room._log('Setting observers failed, this will cause issues', e);
|
|
175
175
|
});
|
|
176
176
|
} else if (msg.action === 'bitrate_changed') {
|
|
@@ -286,15 +286,9 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
286
286
|
}
|
|
287
287
|
},
|
|
288
288
|
|
|
289
|
-
setRoomVars: (
|
|
289
|
+
setRoomVars: () => {
|
|
290
290
|
return wt.room.getRoomById(roomId, pinHash)
|
|
291
291
|
.then(r => {
|
|
292
|
-
if (emit) {
|
|
293
|
-
// emiting "fake" playerSource event
|
|
294
|
-
//TODO: somehow push into sync modules instead
|
|
295
|
-
emitter.emit('changePlayerSource', r.data.wtChannelId, true);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
292
|
// setting observers userId's so we can ignore them when creating participant
|
|
299
293
|
room.setObserverIds(r.data.allowedObservers);
|
|
300
294
|
room.setTalkbackIds(r.data.allowedTalkbacks);
|
|
@@ -429,7 +429,7 @@ const syncVodDashJs = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
429
429
|
timestamp: new Date().getTime(),
|
|
430
430
|
fragment: isPlaying ? "1":"0",
|
|
431
431
|
fragment_pos: Number(fragmentPosition),
|
|
432
|
-
|
|
432
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
433
433
|
}});
|
|
434
434
|
};
|
|
435
435
|
|
|
@@ -328,7 +328,7 @@ const syncDashJs = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
328
328
|
timestamp: new Date().getTime(),
|
|
329
329
|
fragment: String("0"),
|
|
330
330
|
fragment_pos: Number(fragmentPosition),
|
|
331
|
-
slave_id:Number(slaveId)
|
|
331
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
332
332
|
}});
|
|
333
333
|
};
|
|
334
334
|
|
|
@@ -335,7 +335,7 @@ const syncDaznDash = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
335
335
|
timestamp: new Date().getTime(),
|
|
336
336
|
fragment: String("0"),
|
|
337
337
|
fragment_pos: Number(fragmentPosition),
|
|
338
|
-
slave_id:Number(slaveId)
|
|
338
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
339
339
|
}});
|
|
340
340
|
};
|
|
341
341
|
|
|
@@ -326,7 +326,7 @@ const syncDoris = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
326
326
|
timestamp: new Date().getTime(),
|
|
327
327
|
fragment: String("0"),
|
|
328
328
|
fragment_pos: Number(fragmentPosition),
|
|
329
|
-
slave_id:Number(slaveId)
|
|
329
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
330
330
|
}});
|
|
331
331
|
};
|
|
332
332
|
|
|
@@ -429,7 +429,7 @@ const syncVodHlsJs = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
429
429
|
timestamp: new Date().getTime(),
|
|
430
430
|
fragment: isPlaying ? "1":"0",
|
|
431
431
|
fragment_pos: Number(fragmentPosition),
|
|
432
|
-
slave_id:Number(slaveId)
|
|
432
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
433
433
|
}});
|
|
434
434
|
};
|
|
435
435
|
|
|
@@ -499,7 +499,7 @@ const syncHlsJs = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
499
499
|
timestamp: new Date().getTime(),
|
|
500
500
|
fragment: String(fragment),
|
|
501
501
|
fragment_pos: Number(fragmentPosition),
|
|
502
|
-
slave_id:Number(slaveId)
|
|
502
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
503
503
|
}});
|
|
504
504
|
};
|
|
505
505
|
|
|
@@ -421,7 +421,7 @@ const syncVodHlsJs = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
421
421
|
timestamp: new Date().getTime(),
|
|
422
422
|
fragment: isPlaying ? "1":"0",
|
|
423
423
|
fragment_pos: Number(fragmentPosition),
|
|
424
|
-
slave_id:Number(slaveId)
|
|
424
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
425
425
|
}});
|
|
426
426
|
};
|
|
427
427
|
|
|
@@ -331,7 +331,7 @@ const syncNativeHls = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
331
331
|
timestamp: new Date().getTime(),
|
|
332
332
|
fragment: String("0"),
|
|
333
333
|
fragment_pos: Number(fragmentPosition),
|
|
334
|
-
slave_id:Number(slaveId)
|
|
334
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
335
335
|
}});
|
|
336
336
|
};
|
|
337
337
|
|
|
@@ -427,7 +427,7 @@ const syncVodShakaDash = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
427
427
|
timestamp: new Date().getTime(),
|
|
428
428
|
fragment: isPlaying ? "1":"0",
|
|
429
429
|
fragment_pos: Number(fragmentPosition),
|
|
430
|
-
|
|
430
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
431
431
|
}});
|
|
432
432
|
};
|
|
433
433
|
|
|
@@ -341,7 +341,7 @@ const syncDaznDash = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
341
341
|
timestamp: new Date().getTime(),
|
|
342
342
|
fragment: String("0"),
|
|
343
343
|
fragment_pos: Number(fragmentPosition),
|
|
344
|
-
slave_id:Number(slaveId)
|
|
344
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
345
345
|
}});
|
|
346
346
|
};
|
|
347
347
|
|
|
@@ -339,7 +339,7 @@ const syncUniversal = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
339
339
|
timestamp: new Date().getTime(),
|
|
340
340
|
fragment: String("0"),
|
|
341
341
|
fragment_pos: Number(fragmentPosition),
|
|
342
|
-
slave_id:Number(slaveId)
|
|
342
|
+
slave_id: room.webrtcVersion > 1000 ? String(slaveId) : Number(slaveId)
|
|
343
343
|
}});
|
|
344
344
|
};
|
|
345
345
|
|
package/src/modules/wt-room.js
CHANGED
|
@@ -160,6 +160,8 @@ class RoomSession {
|
|
|
160
160
|
this._isStreaming = false;
|
|
161
161
|
this._isPublished = false;
|
|
162
162
|
this._isDataChannelOpen = false;
|
|
163
|
+
this._dataChannelTimeoutId = null;
|
|
164
|
+
this._messageTimeoutId = null;
|
|
163
165
|
this.isAudioMuted = false;
|
|
164
166
|
this.isVideoMuted = false;
|
|
165
167
|
this.isVideoEnabled = false;
|
|
@@ -319,14 +321,12 @@ class RoomSession {
|
|
|
319
321
|
transaction,
|
|
320
322
|
token: this.token, ...((this.sessionId && {'session_id': this.sessionId}) || {})
|
|
321
323
|
};
|
|
322
|
-
let timeouId = null;
|
|
323
|
-
|
|
324
324
|
return new Promise((resolve, reject) => {
|
|
325
325
|
let parseResponse = (event) => {
|
|
326
326
|
let json = JSON.parse(event.data);
|
|
327
327
|
let r_transaction = json['transaction'];
|
|
328
328
|
if (r_transaction === transaction && (!dontResolveOnAck || json['janus'] !== 'ack')) {
|
|
329
|
-
clearTimeout(
|
|
329
|
+
clearTimeout(this._messageTimeoutId);
|
|
330
330
|
this.ws.removeEventListener('message', parseResponse);
|
|
331
331
|
if (json['janus'] === 'error') {
|
|
332
332
|
if (json?.error?.code == 403) {
|
|
@@ -348,7 +348,7 @@ class RoomSession {
|
|
|
348
348
|
} else {
|
|
349
349
|
if (this.ws && this.ws.readyState === 1) {
|
|
350
350
|
this.ws.addEventListener('message', parseResponse);
|
|
351
|
-
|
|
351
|
+
this._messageTimeoutId = setTimeout(() => {
|
|
352
352
|
this.ws.removeEventListener('message', parseResponse);
|
|
353
353
|
reject({type: 'error', id: 3, message: 'send timeout', data: requestData});
|
|
354
354
|
}, 10000);
|
|
@@ -507,6 +507,7 @@ class RoomSession {
|
|
|
507
507
|
"ptype": "subscriber",
|
|
508
508
|
"feed": id,
|
|
509
509
|
"private_id": this.privateId,
|
|
510
|
+
...(this.webrtcVersion > 1000 ? {id: this.userId} : {}),
|
|
510
511
|
pin: this.pin
|
|
511
512
|
}
|
|
512
513
|
})
|
|
@@ -542,6 +543,7 @@ class RoomSession {
|
|
|
542
543
|
"ptype": "subscriber",
|
|
543
544
|
"feed": id,
|
|
544
545
|
"private_id": this.privateId,
|
|
546
|
+
...(this.webrtcVersion > 1000 ? {id: this.userId} : {}),
|
|
545
547
|
pin: this.pin
|
|
546
548
|
}
|
|
547
549
|
})
|
|
@@ -817,10 +819,10 @@ class RoomSession {
|
|
|
817
819
|
})
|
|
818
820
|
}
|
|
819
821
|
|
|
820
|
-
_joinRoom(roomId, pin, userId) {
|
|
822
|
+
_joinRoom(roomId, pin, userId, display) {
|
|
821
823
|
return this.sendMessage(this.handleId, {
|
|
822
824
|
body: {
|
|
823
|
-
"request": "join", "room": roomId, "pin": pin, "ptype": "publisher", "display": userId
|
|
825
|
+
"request": "join", "room": roomId, "pin": pin, "ptype": "publisher", "display": display, ...(this.webrtcVersion > 1000 ? {id: userId} : {})
|
|
824
826
|
}
|
|
825
827
|
}, false, true)
|
|
826
828
|
}
|
|
@@ -892,7 +894,7 @@ class RoomSession {
|
|
|
892
894
|
return this.connectingPromise;
|
|
893
895
|
}
|
|
894
896
|
|
|
895
|
-
connect(roomId, pin, server, iceServers, token, userId, webrtcVersion = 0, initialBitrate = 0, isMonitor, recordingFilename) {
|
|
897
|
+
connect(roomId, pin, server, iceServers, token, display, userId, webrtcVersion = 0, initialBitrate = 0, isMonitor, recordingFilename) {
|
|
896
898
|
|
|
897
899
|
if (this.connectingPromise) {
|
|
898
900
|
return this.connectingPromise;
|
|
@@ -910,7 +912,9 @@ class RoomSession {
|
|
|
910
912
|
this.token = token;
|
|
911
913
|
this.roomId = roomId;
|
|
912
914
|
this.pin = pin;
|
|
915
|
+
this.display = display;
|
|
913
916
|
this.userId = userId;
|
|
917
|
+
this.webrtcVersion = webrtcVersion;
|
|
914
918
|
this.initialBitrate = initialBitrate;
|
|
915
919
|
this.isMonitor = isMonitor;
|
|
916
920
|
this.recordingFilename = recordingFilename;
|
|
@@ -935,7 +939,7 @@ class RoomSession {
|
|
|
935
939
|
this.handleId = handle.handleId;
|
|
936
940
|
return 1
|
|
937
941
|
})
|
|
938
|
-
.then(() => this._joinRoom(roomId, pin, userId))
|
|
942
|
+
.then(() => this._joinRoom(roomId, pin, userId, display))
|
|
939
943
|
.then(() => {
|
|
940
944
|
this.connectingPromise = null;
|
|
941
945
|
this.emit('joining', false);
|
|
@@ -960,7 +964,8 @@ class RoomSession {
|
|
|
960
964
|
if (this.disconnectingPromise) {
|
|
961
965
|
return this.disconnectingPromise;
|
|
962
966
|
}
|
|
963
|
-
|
|
967
|
+
clearTimeout(this._messageTimeoutId);
|
|
968
|
+
clearTimeout(this._dataChannelTimeoutId);
|
|
964
969
|
this._stopKeepAlive();
|
|
965
970
|
this.disconnectingPromise = Promise.all(this._participants.map(p => this._removeParticipant(p.handleId)))
|
|
966
971
|
.finally(() => {
|
|
@@ -1070,7 +1075,6 @@ class RoomSession {
|
|
|
1070
1075
|
return this.disconnectingPromise;
|
|
1071
1076
|
}
|
|
1072
1077
|
|
|
1073
|
-
|
|
1074
1078
|
destroy() {
|
|
1075
1079
|
|
|
1076
1080
|
if (this.sessiontype === 'reactooroom') {
|
|
@@ -1864,12 +1868,12 @@ class RoomSession {
|
|
|
1864
1868
|
return new Promise((resolve, reject) => {
|
|
1865
1869
|
let __ = (val) => {
|
|
1866
1870
|
if (val) {
|
|
1867
|
-
clearTimeout(
|
|
1871
|
+
clearTimeout(this._dataChannelTimeoutId);
|
|
1868
1872
|
this.off('dataChannel', __, this);
|
|
1869
1873
|
resolve(this);
|
|
1870
1874
|
}
|
|
1871
1875
|
};
|
|
1872
|
-
|
|
1876
|
+
this._dataChannelTimeoutId = setTimeout(() => {
|
|
1873
1877
|
this.off('dataChannel', __, this);
|
|
1874
1878
|
reject({type: 'error', id: 27, message: 'Data channel did not open', data: null});
|
|
1875
1879
|
}, 5000);
|