@reactoo/watchtogether-sdk-js 2.4.43 → 2.5.0
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 +1852 -2392
- package/dist/watchtogether-sdk.min.js +2 -2
- package/example/bulk_join_room/bulk_join_room.html +200 -0
- package/example/bulk_join_room/persons_gifs/1.gif +0 -0
- package/example/bulk_join_room/persons_gifs/10.gif +0 -0
- package/example/bulk_join_room/persons_gifs/11.gif +0 -0
- package/example/bulk_join_room/persons_gifs/12.gif +0 -0
- package/example/bulk_join_room/persons_gifs/13.gif +0 -0
- package/example/bulk_join_room/persons_gifs/14.gif +0 -0
- package/example/bulk_join_room/persons_gifs/15.gif +0 -0
- package/example/bulk_join_room/persons_gifs/16.gif +0 -0
- package/example/bulk_join_room/persons_gifs/17.gif +0 -0
- package/example/bulk_join_room/persons_gifs/18.gif +0 -0
- package/example/bulk_join_room/persons_gifs/19.gif +0 -0
- package/example/bulk_join_room/persons_gifs/2.gif +0 -0
- package/example/bulk_join_room/persons_gifs/20.gif +0 -0
- package/example/bulk_join_room/persons_gifs/21.gif +0 -0
- package/example/bulk_join_room/persons_gifs/22.gif +0 -0
- package/example/bulk_join_room/persons_gifs/23.gif +0 -0
- package/example/bulk_join_room/persons_gifs/24.gif +0 -0
- package/example/bulk_join_room/persons_gifs/25.gif +0 -0
- package/example/bulk_join_room/persons_gifs/26.gif +0 -0
- package/example/bulk_join_room/persons_gifs/27.gif +0 -0
- package/example/bulk_join_room/persons_gifs/28.gif +0 -0
- package/example/bulk_join_room/persons_gifs/29.gif +0 -0
- package/example/bulk_join_room/persons_gifs/3.gif +0 -0
- package/example/bulk_join_room/persons_gifs/30.gif +0 -0
- package/example/bulk_join_room/persons_gifs/31.gif +0 -0
- package/example/bulk_join_room/persons_gifs/32.gif +0 -0
- package/example/bulk_join_room/persons_gifs/4.gif +0 -0
- package/example/bulk_join_room/persons_gifs/5.gif +0 -0
- package/example/bulk_join_room/persons_gifs/6.gif +0 -0
- package/example/bulk_join_room/persons_gifs/7.gif +0 -0
- package/example/bulk_join_room/persons_gifs/8.gif +0 -0
- package/example/bulk_join_room/persons_gifs/9.gif +0 -0
- package/example/index.html +19 -13
- package/package.json +2 -2
- package/src/index.js +7 -6
- package/src/models/auth.js +2 -2
- package/src/models/iot.js +81 -70
- package/src/models/room-session.js +24 -10
- package/src/models/room.js +138 -97
- package/src/models/system.js +45 -0
- package/src/models/user.js +6 -3
- package/src/modules/wt-iot.js +124 -74
- package/src/modules/wt-room.js +56 -124
- package/src/modules/wt-utils.js +2 -2
- package/example/shaka-basic-sync.html +0 -137
- package/src/models/iot2.js +0 -119
- package/src/modules/wt-iot2.js +0 -238
package/src/modules/wt-iot.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import {device} from 'aws-iot-device-sdk';
|
|
2
3
|
import emitter from './wt-emitter';
|
|
3
4
|
|
|
4
5
|
class Iot {
|
|
5
6
|
|
|
6
7
|
constructor(enableDebugFlag) {
|
|
7
8
|
Object.assign(this, emitter());
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
9
|
+
this.device = null;
|
|
10
|
+
this.decoder = new TextDecoder('utf-8');
|
|
11
|
+
this.connectionActive = false;
|
|
11
12
|
this.log = Iot.noop;
|
|
13
|
+
this.debugFlag = enableDebugFlag;
|
|
14
|
+
this.credentialsExpirationCheckIntervalId = null;
|
|
15
|
+
this.currentCredentialsExpirationStamp = null
|
|
12
16
|
if(enableDebugFlag) {
|
|
13
17
|
this.enableDebug();
|
|
14
18
|
}
|
|
@@ -20,101 +24,141 @@ class Iot {
|
|
|
20
24
|
this.log = console.log.bind(console);
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
mqttVersion,
|
|
33
|
-
keepAliveInterval: 15,
|
|
34
|
-
reconnect: false
|
|
35
|
-
});
|
|
36
|
-
this.instance.onConnectionLost = this.__closeCb.bind(this);
|
|
37
|
-
this.instance.onMessageArrived = this.__messageCb.bind(this);
|
|
38
|
-
return new Promise((resolve, reject) => {
|
|
39
|
-
let __ = () => {
|
|
40
|
-
this.off('connected', __);
|
|
41
|
-
this.off('error', ___);
|
|
42
|
-
this.off('disconnected', ___);
|
|
43
|
-
resolve(this.instance)
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
let ___ = (e) => {
|
|
47
|
-
this.off('connected', __);
|
|
48
|
-
this.off('error', ___);
|
|
49
|
-
this.off('disconnected', ___);
|
|
50
|
-
reject(e)
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
this.on('connected', __);
|
|
54
|
-
this.on('error', ___);
|
|
55
|
-
this.on('disconnected', ___);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
27
|
+
startCredentialsExpirationCheck(expiration) {
|
|
28
|
+
this.stopCredentialsExpirationCheck();
|
|
29
|
+
this.currentCredentialsExpirationStamp = new Date(expiration).getTime();
|
|
30
|
+
this.credentialsExpirationCheckIntervalId = setInterval(() => {
|
|
31
|
+
const curentTimeStamp = new Date().getTime();
|
|
32
|
+
if(this.currentCredentialsExpirationStamp - curentTimeStamp <= 300000) {
|
|
33
|
+
this.emit('updateCredentials');
|
|
34
|
+
}
|
|
35
|
+
}, 5000);
|
|
58
36
|
}
|
|
59
37
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
38
|
+
stopCredentialsExpirationCheck() {
|
|
39
|
+
clearInterval(this.credentialsExpirationCheckIntervalId);
|
|
40
|
+
this.credentialsExpirationCheckIntervalId = null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
updateWebSocketCredentials(accessKeyId, secretAccessKey, sessionToken, expiration) {
|
|
44
|
+
if(this.device) {
|
|
45
|
+
this.device.updateWebSocketCredentials(accessKeyId, secretAccessKey, sessionToken);
|
|
46
|
+
this.startCredentialsExpirationCheck(expiration);
|
|
68
47
|
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
connect(apiMqttUrl, apiMqttClientId, region, accessKeyId, secretAccessKey, sessionToken, expiration, forceDisconnect = false) {
|
|
51
|
+
return this.disconnect(forceDisconnect).then(() => {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
this.device = device({
|
|
54
|
+
protocol:'wss',
|
|
55
|
+
clientId: apiMqttClientId,
|
|
56
|
+
region,
|
|
57
|
+
host: apiMqttUrl,
|
|
58
|
+
accessKeyId: accessKeyId,
|
|
59
|
+
secretKey: secretAccessKey,
|
|
60
|
+
sessionToken: sessionToken,
|
|
61
|
+
keepalive: 15,
|
|
62
|
+
maximumReconnectTimeMs: 8000,
|
|
63
|
+
enableMetrics: false,
|
|
64
|
+
debug: this.debugFlag,
|
|
65
|
+
autoResubscribe: true
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
this.startCredentialsExpirationCheck(expiration);
|
|
69
|
+
|
|
70
|
+
let __s = () => {
|
|
71
|
+
this.device.off('connect', __s);
|
|
72
|
+
this.device.off('error', __e);
|
|
73
|
+
resolve(this.device)
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
let __e = (e) => {
|
|
77
|
+
this.device.off('connect', __s);
|
|
78
|
+
this.device.off('error', __e);
|
|
79
|
+
reject(e);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
this.device.once('connect', __s);
|
|
83
|
+
this.device.once('error', __e);
|
|
84
|
+
|
|
85
|
+
this.device.on('message', this.__messageCb.bind(this));
|
|
86
|
+
this.device.on('connect', this.__connectCb.bind(this));
|
|
87
|
+
this.device.on('reconnect', this.__reconnectCb.bind(this));
|
|
88
|
+
this.device.on('error', this.__failureCb.bind(this));
|
|
89
|
+
this.device.on('close', this.__closeCb.bind(this));
|
|
90
|
+
this.device.on('offline', this.__offlineCb.bind(this));
|
|
91
|
+
|
|
92
|
+
})
|
|
93
|
+
})
|
|
69
94
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.instance.disconnect();
|
|
81
|
-
} catch (e) {
|
|
82
|
-
return resolve(this.instance);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
disconnect(force = false) {
|
|
98
|
+
|
|
99
|
+
this.stopCredentialsExpirationCheck();
|
|
100
|
+
|
|
101
|
+
return new Promise((resolve, reject) => {
|
|
102
|
+
if(!this.device) {
|
|
103
|
+
resolve();
|
|
104
|
+
return;
|
|
83
105
|
}
|
|
106
|
+
let __i = null;
|
|
107
|
+
let __c = () => {
|
|
108
|
+
clearTimeout(__i);
|
|
109
|
+
this.device = null;
|
|
110
|
+
resolve();
|
|
111
|
+
};
|
|
112
|
+
__i = setTimeout(__c, 4000);
|
|
113
|
+
this.device.off('message', this.__messageCb.bind(this));
|
|
114
|
+
this.device.off('connect', this.__connectCb.bind(this));
|
|
115
|
+
this.device.off('reconnect', this.__reconnectCb.bind(this));
|
|
116
|
+
this.device.off('error', this.__failureCb.bind(this));
|
|
117
|
+
this.device.off('close', this.__closeCb.bind(this));
|
|
118
|
+
this.device.off('offline', this.__offlineCb.bind(this));
|
|
119
|
+
this.device.end(force, __c);
|
|
84
120
|
});
|
|
85
121
|
}
|
|
86
122
|
|
|
87
123
|
isConnected() {
|
|
88
|
-
return this.
|
|
124
|
+
return this.connectionActive;
|
|
89
125
|
}
|
|
90
126
|
|
|
91
127
|
subscribe(topic) {
|
|
92
|
-
return this.
|
|
128
|
+
return this.device && this.device.subscribe(topic);
|
|
93
129
|
}
|
|
94
130
|
|
|
95
131
|
unsubscribe(topic) {
|
|
96
|
-
return this.
|
|
132
|
+
return this.device && this.device.unsubscribe(topic);
|
|
97
133
|
}
|
|
98
134
|
|
|
99
135
|
send(topic, message) {
|
|
100
|
-
let msg =
|
|
101
|
-
|
|
102
|
-
return this.instance && this.instance.send(msg)
|
|
136
|
+
let msg = typeof message === 'object' ? JSON.stringify(message) : message;
|
|
137
|
+
return this.device && this.device.publish(topic, msg);
|
|
103
138
|
}
|
|
104
139
|
|
|
140
|
+
__reconnectCb() {
|
|
141
|
+
this.emit('reconnect');
|
|
142
|
+
}
|
|
105
143
|
__connectCb() {
|
|
106
|
-
this.
|
|
144
|
+
this.connectionActive = true;
|
|
145
|
+
this.emit('connect');
|
|
107
146
|
}
|
|
108
147
|
__failureCb(err) {
|
|
109
148
|
this.emit('error', err);
|
|
110
149
|
}
|
|
111
150
|
__closeCb(responseObject) {
|
|
112
|
-
this.
|
|
151
|
+
this.connectionActive = false;
|
|
152
|
+
this.emit('close');
|
|
113
153
|
}
|
|
114
|
-
|
|
154
|
+
__offlineCb(responseObject) {
|
|
155
|
+
this.emit('offline');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
__messageCb(t, message, packet) {
|
|
115
159
|
|
|
116
|
-
const
|
|
117
|
-
const
|
|
160
|
+
const topic = t.split('/');
|
|
161
|
+
const payload = JSON.parse(this.decoder.decode(message));
|
|
118
162
|
|
|
119
163
|
if(topic[0] === 'user') { // user
|
|
120
164
|
const userId = topic[1].replace("_", ':');
|
|
@@ -137,7 +181,12 @@ class Iot {
|
|
|
137
181
|
event === 'user_update_privateattributes' ||
|
|
138
182
|
event === 'channel_changed' ||
|
|
139
183
|
event === "instance_homepage_changed" ||
|
|
140
|
-
event === "
|
|
184
|
+
event === "instance_settings_changed" ||
|
|
185
|
+
event === "externalmix_changed" ||
|
|
186
|
+
event === "video_uploaded" ||
|
|
187
|
+
event === "change_user_devices" ||
|
|
188
|
+
event === "queue" ||
|
|
189
|
+
event === "title_changed"
|
|
141
190
|
) {
|
|
142
191
|
this.emit('message', {event, ...payload, roomId})
|
|
143
192
|
}
|
|
@@ -154,7 +203,8 @@ class Iot {
|
|
|
154
203
|
event === 'unmuted' ||
|
|
155
204
|
event === 'messageRemoved' ||
|
|
156
205
|
event === 'messageReported' ||
|
|
157
|
-
event === 'chatClear'
|
|
206
|
+
event === 'chatClear' ||
|
|
207
|
+
event === 'handRaised' || event === 'handLowered' || event === 'handsCleared'
|
|
158
208
|
) {
|
|
159
209
|
this.emit('message', {event, ...payload});
|
|
160
210
|
}
|
|
@@ -163,7 +213,7 @@ class Iot {
|
|
|
163
213
|
}
|
|
164
214
|
}
|
|
165
215
|
else if(topic[1] === 'instanceroom') { // instance
|
|
166
|
-
if(event === 'add_room' || event === 'remove_room' || event === 'set_room' || event === "instance_homepage_changed") {
|
|
216
|
+
if(event === 'add_room' || event === 'remove_room' || event === 'set_room' || event === "instance_homepage_changed" || event === 'instance_settings_changed') {
|
|
167
217
|
this.emit('message', {event, ...payload});
|
|
168
218
|
}
|
|
169
219
|
}
|
package/src/modules/wt-room.js
CHANGED
|
@@ -6,87 +6,32 @@ import {generateUUID} from "./wt-utils";
|
|
|
6
6
|
|
|
7
7
|
class Room {
|
|
8
8
|
|
|
9
|
-
constructor(
|
|
10
|
-
|
|
9
|
+
constructor(debug) {
|
|
10
|
+
this.debug = debug;
|
|
11
11
|
this.sessions = [];
|
|
12
12
|
this.safariVp8 = false;
|
|
13
13
|
this.browser = adapter.browserDetails.browser;
|
|
14
14
|
this.browserDetails = adapter.browserDetails;
|
|
15
|
-
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
|
|
16
|
+
this.isWebrtcSupported = Room.isWebrtcSupported();
|
|
17
|
+
this.safariVp8TestPromise = Room.testSafariVp8();
|
|
18
|
+
|
|
19
|
+
this.safariVp8 = null;
|
|
20
|
+
this.safariVp8TestPromise.then(safariVp8 => {
|
|
21
|
+
this.safariVp8 = safariVp8;
|
|
22
|
+
})
|
|
23
|
+
|
|
22
24
|
// Let's get it started
|
|
23
|
-
this.
|
|
25
|
+
this.whenInitialized = this.initialize();
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
initialize() {
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
resolve(this);
|
|
30
|
-
}
|
|
31
|
-
if (!Room.isWebrtcSupported()) {
|
|
32
|
-
reject({type: 'error', id: 0, message: 'WebRTC is not supported on this platform', data: null})
|
|
33
|
-
}
|
|
34
|
-
Room.testSafariVp8()
|
|
35
|
-
.then(isVP8 => {
|
|
36
|
-
this.setExitListeners();
|
|
37
|
-
this.safariVp8 = isVP8;
|
|
38
|
-
this.initialized = true;
|
|
39
|
-
return adapter.browserDetails.browser !== 'safari' || (this.safariVp8) //&& 'MediaSource' in window
|
|
40
|
-
? resolve(this)
|
|
41
|
-
: reject({type: 'error', id: 0, message: 'This browser is not supported', data: null})
|
|
42
|
-
});
|
|
43
|
-
});
|
|
29
|
+
return this.safariVp8TestPromise
|
|
30
|
+
.then(() => this);
|
|
44
31
|
}
|
|
45
32
|
|
|
46
|
-
createSession(type = 'reactooroom', options = {}) {
|
|
47
|
-
|
|
48
|
-
this.sessions.push(session);
|
|
49
|
-
return session;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
closeSessionByConstructId(constructId) {
|
|
53
|
-
let sessionIndex = this.sessions.findIndex(session => session.constructId === constructId);
|
|
54
|
-
if (sessionIndex > -1) {
|
|
55
|
-
return this.sessions[sessionIndex].destroy()
|
|
56
|
-
.then(() => {
|
|
57
|
-
this.sessions.splice(sessionIndex, 1);
|
|
58
|
-
return true
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
return Promise.resolve();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
closeSessionBySessionId(sessionId) {
|
|
65
|
-
let sessionIndex = this.sessions.findIndex(session => session.sessionId === sessionId);
|
|
66
|
-
if (sessionIndex > -1) {
|
|
67
|
-
return this.sessions[sessionIndex].destroy()
|
|
68
|
-
.then(() => {
|
|
69
|
-
this.sessions.splice(sessionIndex, 1);
|
|
70
|
-
return true
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
return Promise.resolve();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
closeSessions() {
|
|
77
|
-
this.sessions.forEach(session => session.destroy().catch(e => this.log(e)));
|
|
78
|
-
this.sessions.length = 0;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
setExitListeners() {
|
|
82
|
-
window.addEventListener('pagehide', (event) => {
|
|
83
|
-
if (!event.persisted) {
|
|
84
|
-
this.closeSessions()
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
window.addEventListener('beforeunload', () => {
|
|
88
|
-
this.closeSessions()
|
|
89
|
-
});
|
|
33
|
+
createSession(constructId = null, type = 'reactooroom', options = {}) {
|
|
34
|
+
return new RoomSession(constructId, type, this.debug, options);
|
|
90
35
|
}
|
|
91
36
|
|
|
92
37
|
static testSafariVp8() {
|
|
@@ -119,28 +64,11 @@ class Room {
|
|
|
119
64
|
});
|
|
120
65
|
}
|
|
121
66
|
|
|
122
|
-
static randomString(len) {
|
|
123
|
-
var charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
124
|
-
var randomString = '';
|
|
125
|
-
for (var i = 0; i < len; i++) {
|
|
126
|
-
var randomPoz = Math.floor(Math.random() * charSet.length);
|
|
127
|
-
randomString += charSet.substring(randomPoz, randomPoz + 1);
|
|
128
|
-
}
|
|
129
|
-
return randomString;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
67
|
static isWebrtcSupported() {
|
|
133
68
|
return window.RTCPeerConnection !== undefined && window.RTCPeerConnection !== null &&
|
|
134
69
|
navigator.mediaDevices !== undefined && navigator.mediaDevices !== null &&
|
|
135
70
|
navigator.mediaDevices.getUserMedia !== undefined && navigator.mediaDevices.getUserMedia !== null;
|
|
136
71
|
}
|
|
137
|
-
|
|
138
|
-
static noop() {
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
enableDebug() {
|
|
142
|
-
this.log = console.log.bind(console);
|
|
143
|
-
}
|
|
144
72
|
}
|
|
145
73
|
|
|
146
74
|
class RoomSession {
|
|
@@ -148,6 +76,16 @@ class RoomSession {
|
|
|
148
76
|
static noop() {
|
|
149
77
|
|
|
150
78
|
}
|
|
79
|
+
|
|
80
|
+
static randomString(len) {
|
|
81
|
+
var charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
82
|
+
var randomString = '';
|
|
83
|
+
for (var i = 0; i < len; i++) {
|
|
84
|
+
var randomPoz = Math.floor(Math.random() * charSet.length);
|
|
85
|
+
randomString += charSet.substring(randomPoz, randomPoz + 1);
|
|
86
|
+
}
|
|
87
|
+
return randomString;
|
|
88
|
+
}
|
|
151
89
|
|
|
152
90
|
//TODO: solve
|
|
153
91
|
// #eventList = ['error', 'kicked', 'addLocalParticipant', ,'addRemoteInstructor','addRemoteParticipant','addRemoteTalkback', 'addRemoteObserver', 'removeRemoteInstructor', 'removeLocalParticipant', 'removeRemoteParticipant', 'removeRemoteTalkback', 'removeRemoteObserver', 'localMuted', 'localHasVideo', 'localHasAudio', 'data', 'iceState', 'connectionState', 'joined', 'joining', 'dataChannel', 'disconnect', 'observerIds', 'talkbackIds', 'instructorId', 'published', 'publishing', 'remoteTrackMuted', 'streamingStatus', 'streaming', 'streamStarting'];
|
|
@@ -164,7 +102,7 @@ class RoomSession {
|
|
|
164
102
|
}
|
|
165
103
|
};
|
|
166
104
|
|
|
167
|
-
constructor(
|
|
105
|
+
constructor(constructId = null, type = 'reactooroom', debug, options = {}) {
|
|
168
106
|
this.server = null;
|
|
169
107
|
this.iceServers = null;
|
|
170
108
|
this.token = null;
|
|
@@ -179,20 +117,20 @@ class RoomSession {
|
|
|
179
117
|
this.pluginName = RoomSession.sessionTypes()[type];
|
|
180
118
|
this.options = {
|
|
181
119
|
...{
|
|
120
|
+
debug: debug,
|
|
182
121
|
classroomObserverSubscribeToInstructor: false,
|
|
183
122
|
classroomInstructorSubscribeToParticipants: false,
|
|
184
123
|
safariBugHotfixEnabled: adapter.browserDetails.browser === 'safari' && adapter.browserDetails.version < 605
|
|
185
124
|
},
|
|
186
125
|
options
|
|
187
126
|
};
|
|
188
|
-
//this.pluginName = this.#sessionTypes[type];
|
|
189
127
|
|
|
190
128
|
Object.assign(this, emitter());
|
|
191
129
|
|
|
192
130
|
this.id = null;
|
|
193
131
|
this.privateId = null;
|
|
194
132
|
|
|
195
|
-
this.constructId =
|
|
133
|
+
this.constructId = constructId || RoomSession.randomString(16);
|
|
196
134
|
this.sessionId = null;
|
|
197
135
|
this.handleId = null;
|
|
198
136
|
this.ws = null;
|
|
@@ -219,11 +157,11 @@ class RoomSession {
|
|
|
219
157
|
this.isVideoMuted = false;
|
|
220
158
|
this.isVideoEnabled = false;
|
|
221
159
|
this.isAudioEnabed = false;
|
|
222
|
-
|
|
160
|
+
|
|
223
161
|
this.isUnifiedPlan = RoomSession.checkUnifiedPlan();
|
|
224
|
-
|
|
162
|
+
|
|
225
163
|
this._log = RoomSession.noop;
|
|
226
|
-
if (
|
|
164
|
+
if (this.options.debug) {
|
|
227
165
|
this._enableDebug();
|
|
228
166
|
}
|
|
229
167
|
}
|
|
@@ -281,8 +219,7 @@ class RoomSession {
|
|
|
281
219
|
}
|
|
282
220
|
|
|
283
221
|
_send(request = {}, ignoreResponse = false, dontResolveOnAck = false) {
|
|
284
|
-
|
|
285
|
-
let transaction = Room.randomString(12);
|
|
222
|
+
let transaction = RoomSession.randomString(12);
|
|
286
223
|
let requestData = {
|
|
287
224
|
...request,
|
|
288
225
|
transaction,
|
|
@@ -488,7 +425,7 @@ class RoomSession {
|
|
|
488
425
|
/*
|
|
489
426
|
|
|
490
427
|
monitor/talkback -> all but talkback
|
|
491
|
-
observer -> all but
|
|
428
|
+
observer -> all but talkback
|
|
492
429
|
instructor -> no one
|
|
493
430
|
participant -> only instructor, observer and talkback
|
|
494
431
|
|
|
@@ -584,13 +521,13 @@ class RoomSession {
|
|
|
584
521
|
/*
|
|
585
522
|
|
|
586
523
|
monitor/talkback -> all but talkback
|
|
587
|
-
observer -> all but
|
|
524
|
+
observer -> all but talkback
|
|
588
525
|
instructor -> no one
|
|
589
526
|
participant -> only instructor, observer and talkback
|
|
590
527
|
|
|
591
528
|
1st line -> Im not monitor/talkback and im not observer and im not instructor and user to subscribe is instructor or observer or talkback
|
|
592
529
|
2nd line -> Im monitor/talkback and im not instructor and user connecting is not talkback
|
|
593
|
-
3rd line ->
|
|
530
|
+
3rd line -> Im observer and im not instructor and user connecting is not talkback
|
|
594
531
|
|
|
595
532
|
*/
|
|
596
533
|
|
|
@@ -711,7 +648,7 @@ class RoomSession {
|
|
|
711
648
|
"request": "configure",
|
|
712
649
|
"bitrate": this.initialBitrate
|
|
713
650
|
}
|
|
714
|
-
}).catch(
|
|
651
|
+
}).catch(() => null)
|
|
715
652
|
}
|
|
716
653
|
}
|
|
717
654
|
}
|
|
@@ -780,17 +717,13 @@ class RoomSession {
|
|
|
780
717
|
}
|
|
781
718
|
|
|
782
719
|
if (type === 'error') {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
message: 'data event error',
|
|
791
|
-
data: [handleId, data]
|
|
792
|
-
});
|
|
793
|
-
}
|
|
720
|
+
|
|
721
|
+
this.emit('error', {
|
|
722
|
+
type: 'warning',
|
|
723
|
+
id: 9,
|
|
724
|
+
message: 'data event warning',
|
|
725
|
+
data: [handleId, data]
|
|
726
|
+
});
|
|
794
727
|
|
|
795
728
|
if (handle) {
|
|
796
729
|
let config = handle.webrtcStuff;
|
|
@@ -819,7 +752,6 @@ class RoomSession {
|
|
|
819
752
|
|
|
820
753
|
//removeHandle === true -> hangup, detach, removeHandle === false -> hangup
|
|
821
754
|
_removeParticipant(handleId, rfid, removeHandle = true) {
|
|
822
|
-
|
|
823
755
|
let handle = this._getHandle(handleId, rfid);
|
|
824
756
|
|
|
825
757
|
if (!handle) {
|
|
@@ -858,7 +790,7 @@ class RoomSession {
|
|
|
858
790
|
try {
|
|
859
791
|
handle.webrtcStuff.pc.close();
|
|
860
792
|
} catch (e) {
|
|
861
|
-
|
|
793
|
+
|
|
862
794
|
}
|
|
863
795
|
handle.webrtcStuff = {
|
|
864
796
|
stream: null,
|
|
@@ -872,11 +804,6 @@ class RoomSession {
|
|
|
872
804
|
iceDone: false,
|
|
873
805
|
};
|
|
874
806
|
|
|
875
|
-
if (removeHandle) {
|
|
876
|
-
let handleIndex = this._participants.findIndex(p => p.handleId === handleId);
|
|
877
|
-
this._participants.splice(handleIndex, 1);
|
|
878
|
-
}
|
|
879
|
-
|
|
880
807
|
if (handleId === this.handleId) {
|
|
881
808
|
this._isDataChannelOpen = false;
|
|
882
809
|
this._isPublished = false;
|
|
@@ -898,6 +825,11 @@ class RoomSession {
|
|
|
898
825
|
}
|
|
899
826
|
this.emit(eventName, {id: handleId, userId: handle.userId});
|
|
900
827
|
}
|
|
828
|
+
|
|
829
|
+
if (removeHandle) {
|
|
830
|
+
let handleIndex = this._participants.findIndex(p => p.handleId === handleId);
|
|
831
|
+
this._participants.splice(handleIndex, 1);
|
|
832
|
+
}
|
|
901
833
|
|
|
902
834
|
return true;
|
|
903
835
|
});
|
|
@@ -950,7 +882,7 @@ class RoomSession {
|
|
|
950
882
|
_leaveRoom(dontWait = false) {
|
|
951
883
|
return this._hasJoined
|
|
952
884
|
? this.sendMessage(this.handleId, {body: {"request": "leave"}}, dontWait)
|
|
953
|
-
.finally((
|
|
885
|
+
.finally(() => {
|
|
954
886
|
this._hasJoined = false;
|
|
955
887
|
this.emit('joined', false);
|
|
956
888
|
})
|
|
@@ -1070,7 +1002,7 @@ class RoomSession {
|
|
|
1070
1002
|
return this.connectingPromise;
|
|
1071
1003
|
}
|
|
1072
1004
|
|
|
1073
|
-
disconnect(
|
|
1005
|
+
disconnect() {
|
|
1074
1006
|
if (this.disconnectingPromise) {
|
|
1075
1007
|
return this.disconnectingPromise;
|
|
1076
1008
|
}
|
|
@@ -1079,8 +1011,8 @@ class RoomSession {
|
|
|
1079
1011
|
this.disconnectingPromise = Promise.all(this._participants.map(p => this._removeParticipant(p.handleId)))
|
|
1080
1012
|
.finally(() => {
|
|
1081
1013
|
this._wipeListeners();
|
|
1082
|
-
this._send({"janus": "destroy"}, true);
|
|
1083
1014
|
if (this.ws && this.ws.readyState === 1) {
|
|
1015
|
+
this._send({"janus": "destroy"}, true);
|
|
1084
1016
|
this.ws.close();
|
|
1085
1017
|
}
|
|
1086
1018
|
this.sessionId = null;
|
|
@@ -1185,16 +1117,16 @@ class RoomSession {
|
|
|
1185
1117
|
}
|
|
1186
1118
|
|
|
1187
1119
|
|
|
1188
|
-
destroy(
|
|
1120
|
+
destroy() {
|
|
1189
1121
|
|
|
1190
1122
|
if (this.sessiontype === 'reactooroom') {
|
|
1191
|
-
return this.disconnect(
|
|
1123
|
+
return this.disconnect()
|
|
1192
1124
|
.then(() => {
|
|
1193
1125
|
this.clear();
|
|
1194
1126
|
return true;
|
|
1195
1127
|
});
|
|
1196
1128
|
} else if (this.sessiontype === 'streaming') {
|
|
1197
|
-
return this.stopStream(
|
|
1129
|
+
return this.stopStream()
|
|
1198
1130
|
.then(() => {
|
|
1199
1131
|
this.clear();
|
|
1200
1132
|
return true
|
package/src/modules/wt-utils.js
CHANGED
|
@@ -2,14 +2,14 @@ import Fingerprint2 from '@fingerprintjs/fingerprintjs';
|
|
|
2
2
|
|
|
3
3
|
let wait = function(ms) { return new Promise(resolve => setTimeout(resolve, ms))};
|
|
4
4
|
|
|
5
|
-
let getBrowserFingerprint = function (instanceType = '') {
|
|
5
|
+
let getBrowserFingerprint = function (instanceType = '', salt = '') {
|
|
6
6
|
return new Promise((resolve) => {
|
|
7
7
|
let options = {
|
|
8
8
|
extraComponents : [
|
|
9
9
|
{
|
|
10
10
|
key: 'instanceType',
|
|
11
11
|
getData: function (done, options) {
|
|
12
|
-
done(instanceType)
|
|
12
|
+
done(instanceType + '_' + salt)
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
]
|