@reactoo/watchtogether-sdk-js 2.5.23 → 2.5.24
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.
|
@@ -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
|
@@ -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: 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);
|
|
@@ -960,7 +960,8 @@ class RoomSession {
|
|
|
960
960
|
if (this.disconnectingPromise) {
|
|
961
961
|
return this.disconnectingPromise;
|
|
962
962
|
}
|
|
963
|
-
|
|
963
|
+
clearTimeout(this._messageTimeoutId);
|
|
964
|
+
clearTimeout(this._dataChannelTimeoutId);
|
|
964
965
|
this._stopKeepAlive();
|
|
965
966
|
this.disconnectingPromise = Promise.all(this._participants.map(p => this._removeParticipant(p.handleId)))
|
|
966
967
|
.finally(() => {
|
|
@@ -1864,12 +1865,12 @@ class RoomSession {
|
|
|
1864
1865
|
return new Promise((resolve, reject) => {
|
|
1865
1866
|
let __ = (val) => {
|
|
1866
1867
|
if (val) {
|
|
1867
|
-
clearTimeout(
|
|
1868
|
+
clearTimeout(this._dataChannelTimeoutId);
|
|
1868
1869
|
this.off('dataChannel', __, this);
|
|
1869
1870
|
resolve(this);
|
|
1870
1871
|
}
|
|
1871
1872
|
};
|
|
1872
|
-
|
|
1873
|
+
this._dataChannelTimeoutId = setTimeout(() => {
|
|
1873
1874
|
this.off('dataChannel', __, this);
|
|
1874
1875
|
reject({type: 'error', id: 27, message: 'Data channel did not open', data: null});
|
|
1875
1876
|
}, 5000);
|