@reactoo/watchtogether-sdk-js 2.4.40 → 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 +2187 -2418
- 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 +8 -8
- 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 +31 -12
- package/src/models/room.js +138 -97
- package/src/models/system.js +45 -0
- package/src/models/user.js +11 -6
- package/src/modules/wt-iot.js +124 -74
- package/src/modules/wt-room.js +65 -131
- 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
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
createSession(type = 'reactooroom', options = {}) {
|
|
47
|
-
let session = new RoomSession(this.enableDebugFlag, type, options);
|
|
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();
|
|
29
|
+
return this.safariVp8TestPromise
|
|
30
|
+
.then(() => this);
|
|
74
31
|
}
|
|
75
32
|
|
|
76
|
-
|
|
77
|
-
|
|
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,12 +102,7 @@ class RoomSession {
|
|
|
164
102
|
}
|
|
165
103
|
};
|
|
166
104
|
|
|
167
|
-
constructor(
|
|
168
|
-
classroomObserverSubscribeToInstructor: false,
|
|
169
|
-
classroomInstructorSubscribeToParticipants: false,
|
|
170
|
-
safariBugHotfixEnabled: true
|
|
171
|
-
}) {
|
|
172
|
-
|
|
105
|
+
constructor(constructId = null, type = 'reactooroom', debug, options = {}) {
|
|
173
106
|
this.server = null;
|
|
174
107
|
this.iceServers = null;
|
|
175
108
|
this.token = null;
|
|
@@ -182,15 +115,22 @@ class RoomSession {
|
|
|
182
115
|
this.isMonitor = false; // currently used just for classroom context so monitor user only subscribes to participants and not trainer (for other monitor this flag is not necessary)
|
|
183
116
|
this.recordingFilename = null;
|
|
184
117
|
this.pluginName = RoomSession.sessionTypes()[type];
|
|
185
|
-
this.options =
|
|
186
|
-
|
|
118
|
+
this.options = {
|
|
119
|
+
...{
|
|
120
|
+
debug: debug,
|
|
121
|
+
classroomObserverSubscribeToInstructor: false,
|
|
122
|
+
classroomInstructorSubscribeToParticipants: false,
|
|
123
|
+
safariBugHotfixEnabled: adapter.browserDetails.browser === 'safari' && adapter.browserDetails.version < 605
|
|
124
|
+
},
|
|
125
|
+
options
|
|
126
|
+
};
|
|
187
127
|
|
|
188
128
|
Object.assign(this, emitter());
|
|
189
129
|
|
|
190
130
|
this.id = null;
|
|
191
131
|
this.privateId = null;
|
|
192
132
|
|
|
193
|
-
this.constructId =
|
|
133
|
+
this.constructId = constructId || RoomSession.randomString(16);
|
|
194
134
|
this.sessionId = null;
|
|
195
135
|
this.handleId = null;
|
|
196
136
|
this.ws = null;
|
|
@@ -217,11 +157,11 @@ class RoomSession {
|
|
|
217
157
|
this.isVideoMuted = false;
|
|
218
158
|
this.isVideoEnabled = false;
|
|
219
159
|
this.isAudioEnabed = false;
|
|
220
|
-
|
|
160
|
+
|
|
221
161
|
this.isUnifiedPlan = RoomSession.checkUnifiedPlan();
|
|
222
|
-
|
|
162
|
+
|
|
223
163
|
this._log = RoomSession.noop;
|
|
224
|
-
if (
|
|
164
|
+
if (this.options.debug) {
|
|
225
165
|
this._enableDebug();
|
|
226
166
|
}
|
|
227
167
|
}
|
|
@@ -279,8 +219,7 @@ class RoomSession {
|
|
|
279
219
|
}
|
|
280
220
|
|
|
281
221
|
_send(request = {}, ignoreResponse = false, dontResolveOnAck = false) {
|
|
282
|
-
|
|
283
|
-
let transaction = Room.randomString(12);
|
|
222
|
+
let transaction = RoomSession.randomString(12);
|
|
284
223
|
let requestData = {
|
|
285
224
|
...request,
|
|
286
225
|
transaction,
|
|
@@ -486,7 +425,7 @@ class RoomSession {
|
|
|
486
425
|
/*
|
|
487
426
|
|
|
488
427
|
monitor/talkback -> all but talkback
|
|
489
|
-
observer -> all but
|
|
428
|
+
observer -> all but talkback
|
|
490
429
|
instructor -> no one
|
|
491
430
|
participant -> only instructor, observer and talkback
|
|
492
431
|
|
|
@@ -582,13 +521,13 @@ class RoomSession {
|
|
|
582
521
|
/*
|
|
583
522
|
|
|
584
523
|
monitor/talkback -> all but talkback
|
|
585
|
-
observer -> all but
|
|
524
|
+
observer -> all but talkback
|
|
586
525
|
instructor -> no one
|
|
587
526
|
participant -> only instructor, observer and talkback
|
|
588
527
|
|
|
589
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
|
|
590
529
|
2nd line -> Im monitor/talkback and im not instructor and user connecting is not talkback
|
|
591
|
-
3rd line ->
|
|
530
|
+
3rd line -> Im observer and im not instructor and user connecting is not talkback
|
|
592
531
|
|
|
593
532
|
*/
|
|
594
533
|
|
|
@@ -709,7 +648,7 @@ class RoomSession {
|
|
|
709
648
|
"request": "configure",
|
|
710
649
|
"bitrate": this.initialBitrate
|
|
711
650
|
}
|
|
712
|
-
}).catch(
|
|
651
|
+
}).catch(() => null)
|
|
713
652
|
}
|
|
714
653
|
}
|
|
715
654
|
}
|
|
@@ -778,17 +717,13 @@ class RoomSession {
|
|
|
778
717
|
}
|
|
779
718
|
|
|
780
719
|
if (type === 'error') {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
message: 'data event error',
|
|
789
|
-
data: [handleId, data]
|
|
790
|
-
});
|
|
791
|
-
}
|
|
720
|
+
|
|
721
|
+
this.emit('error', {
|
|
722
|
+
type: 'warning',
|
|
723
|
+
id: 9,
|
|
724
|
+
message: 'data event warning',
|
|
725
|
+
data: [handleId, data]
|
|
726
|
+
});
|
|
792
727
|
|
|
793
728
|
if (handle) {
|
|
794
729
|
let config = handle.webrtcStuff;
|
|
@@ -817,7 +752,6 @@ class RoomSession {
|
|
|
817
752
|
|
|
818
753
|
//removeHandle === true -> hangup, detach, removeHandle === false -> hangup
|
|
819
754
|
_removeParticipant(handleId, rfid, removeHandle = true) {
|
|
820
|
-
|
|
821
755
|
let handle = this._getHandle(handleId, rfid);
|
|
822
756
|
|
|
823
757
|
if (!handle) {
|
|
@@ -856,7 +790,7 @@ class RoomSession {
|
|
|
856
790
|
try {
|
|
857
791
|
handle.webrtcStuff.pc.close();
|
|
858
792
|
} catch (e) {
|
|
859
|
-
|
|
793
|
+
|
|
860
794
|
}
|
|
861
795
|
handle.webrtcStuff = {
|
|
862
796
|
stream: null,
|
|
@@ -870,11 +804,6 @@ class RoomSession {
|
|
|
870
804
|
iceDone: false,
|
|
871
805
|
};
|
|
872
806
|
|
|
873
|
-
if (removeHandle) {
|
|
874
|
-
let handleIndex = this._participants.findIndex(p => p.handleId === handleId);
|
|
875
|
-
this._participants.splice(handleIndex, 1);
|
|
876
|
-
}
|
|
877
|
-
|
|
878
807
|
if (handleId === this.handleId) {
|
|
879
808
|
this._isDataChannelOpen = false;
|
|
880
809
|
this._isPublished = false;
|
|
@@ -896,6 +825,11 @@ class RoomSession {
|
|
|
896
825
|
}
|
|
897
826
|
this.emit(eventName, {id: handleId, userId: handle.userId});
|
|
898
827
|
}
|
|
828
|
+
|
|
829
|
+
if (removeHandle) {
|
|
830
|
+
let handleIndex = this._participants.findIndex(p => p.handleId === handleId);
|
|
831
|
+
this._participants.splice(handleIndex, 1);
|
|
832
|
+
}
|
|
899
833
|
|
|
900
834
|
return true;
|
|
901
835
|
});
|
|
@@ -948,7 +882,7 @@ class RoomSession {
|
|
|
948
882
|
_leaveRoom(dontWait = false) {
|
|
949
883
|
return this._hasJoined
|
|
950
884
|
? this.sendMessage(this.handleId, {body: {"request": "leave"}}, dontWait)
|
|
951
|
-
.finally((
|
|
885
|
+
.finally(() => {
|
|
952
886
|
this._hasJoined = false;
|
|
953
887
|
this.emit('joined', false);
|
|
954
888
|
})
|
|
@@ -1068,7 +1002,7 @@ class RoomSession {
|
|
|
1068
1002
|
return this.connectingPromise;
|
|
1069
1003
|
}
|
|
1070
1004
|
|
|
1071
|
-
disconnect(
|
|
1005
|
+
disconnect() {
|
|
1072
1006
|
if (this.disconnectingPromise) {
|
|
1073
1007
|
return this.disconnectingPromise;
|
|
1074
1008
|
}
|
|
@@ -1077,8 +1011,8 @@ class RoomSession {
|
|
|
1077
1011
|
this.disconnectingPromise = Promise.all(this._participants.map(p => this._removeParticipant(p.handleId)))
|
|
1078
1012
|
.finally(() => {
|
|
1079
1013
|
this._wipeListeners();
|
|
1080
|
-
this._send({"janus": "destroy"}, true);
|
|
1081
1014
|
if (this.ws && this.ws.readyState === 1) {
|
|
1015
|
+
this._send({"janus": "destroy"}, true);
|
|
1082
1016
|
this.ws.close();
|
|
1083
1017
|
}
|
|
1084
1018
|
this.sessionId = null;
|
|
@@ -1183,16 +1117,16 @@ class RoomSession {
|
|
|
1183
1117
|
}
|
|
1184
1118
|
|
|
1185
1119
|
|
|
1186
|
-
destroy(
|
|
1120
|
+
destroy() {
|
|
1187
1121
|
|
|
1188
1122
|
if (this.sessiontype === 'reactooroom') {
|
|
1189
|
-
return this.disconnect(
|
|
1123
|
+
return this.disconnect()
|
|
1190
1124
|
.then(() => {
|
|
1191
1125
|
this.clear();
|
|
1192
1126
|
return true;
|
|
1193
1127
|
});
|
|
1194
1128
|
} else if (this.sessiontype === 'streaming') {
|
|
1195
|
-
return this.stopStream(
|
|
1129
|
+
return this.stopStream()
|
|
1196
1130
|
.then(() => {
|
|
1197
1131
|
this.clear();
|
|
1198
1132
|
return true
|
|
@@ -2001,7 +1935,7 @@ class RoomSession {
|
|
|
2001
1935
|
}
|
|
2002
1936
|
let config = handle.webrtcStuff;
|
|
2003
1937
|
|
|
2004
|
-
if(this.options.safariBugHotfixEnabled
|
|
1938
|
+
if(this.options.safariBugHotfixEnabled) {
|
|
2005
1939
|
this.isVideoMuted = !this.isVideoMuted;
|
|
2006
1940
|
}
|
|
2007
1941
|
else if (this.isUnifiedPlan) {
|
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
|
]
|