@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.
Files changed (50) hide show
  1. package/dist/watchtogether-sdk.js +2187 -2418
  2. package/dist/watchtogether-sdk.min.js +2 -2
  3. package/example/bulk_join_room/bulk_join_room.html +200 -0
  4. package/example/bulk_join_room/persons_gifs/1.gif +0 -0
  5. package/example/bulk_join_room/persons_gifs/10.gif +0 -0
  6. package/example/bulk_join_room/persons_gifs/11.gif +0 -0
  7. package/example/bulk_join_room/persons_gifs/12.gif +0 -0
  8. package/example/bulk_join_room/persons_gifs/13.gif +0 -0
  9. package/example/bulk_join_room/persons_gifs/14.gif +0 -0
  10. package/example/bulk_join_room/persons_gifs/15.gif +0 -0
  11. package/example/bulk_join_room/persons_gifs/16.gif +0 -0
  12. package/example/bulk_join_room/persons_gifs/17.gif +0 -0
  13. package/example/bulk_join_room/persons_gifs/18.gif +0 -0
  14. package/example/bulk_join_room/persons_gifs/19.gif +0 -0
  15. package/example/bulk_join_room/persons_gifs/2.gif +0 -0
  16. package/example/bulk_join_room/persons_gifs/20.gif +0 -0
  17. package/example/bulk_join_room/persons_gifs/21.gif +0 -0
  18. package/example/bulk_join_room/persons_gifs/22.gif +0 -0
  19. package/example/bulk_join_room/persons_gifs/23.gif +0 -0
  20. package/example/bulk_join_room/persons_gifs/24.gif +0 -0
  21. package/example/bulk_join_room/persons_gifs/25.gif +0 -0
  22. package/example/bulk_join_room/persons_gifs/26.gif +0 -0
  23. package/example/bulk_join_room/persons_gifs/27.gif +0 -0
  24. package/example/bulk_join_room/persons_gifs/28.gif +0 -0
  25. package/example/bulk_join_room/persons_gifs/29.gif +0 -0
  26. package/example/bulk_join_room/persons_gifs/3.gif +0 -0
  27. package/example/bulk_join_room/persons_gifs/30.gif +0 -0
  28. package/example/bulk_join_room/persons_gifs/31.gif +0 -0
  29. package/example/bulk_join_room/persons_gifs/32.gif +0 -0
  30. package/example/bulk_join_room/persons_gifs/4.gif +0 -0
  31. package/example/bulk_join_room/persons_gifs/5.gif +0 -0
  32. package/example/bulk_join_room/persons_gifs/6.gif +0 -0
  33. package/example/bulk_join_room/persons_gifs/7.gif +0 -0
  34. package/example/bulk_join_room/persons_gifs/8.gif +0 -0
  35. package/example/bulk_join_room/persons_gifs/9.gif +0 -0
  36. package/example/index.html +19 -13
  37. package/package.json +8 -8
  38. package/src/index.js +7 -6
  39. package/src/models/auth.js +2 -2
  40. package/src/models/iot.js +81 -70
  41. package/src/models/room-session.js +31 -12
  42. package/src/models/room.js +138 -97
  43. package/src/models/system.js +45 -0
  44. package/src/models/user.js +11 -6
  45. package/src/modules/wt-iot.js +124 -74
  46. package/src/modules/wt-room.js +65 -131
  47. package/src/modules/wt-utils.js +2 -2
  48. package/example/shaka-basic-sync.html +0 -137
  49. package/src/models/iot2.js +0 -119
  50. package/src/modules/wt-iot2.js +0 -238
@@ -1,14 +1,18 @@
1
- import Paho from 'paho-mqtt';
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.debug = enableDebugFlag;
9
- this.instance = null;
10
- this.promise = null;
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
- connect(apiMqttUrl, apiMqttClientId, timeout = 5, mqttVersion, useSSL) {
24
- return this.promise = this.disconnect()
25
- .then(() => {
26
- this.instance = new Paho.Client(apiMqttUrl, apiMqttClientId);
27
- this.instance.connect({
28
- onSuccess: this.__connectCb.bind(this),
29
- onFailure: this.__failureCb.bind(this),
30
- useSSL,
31
- timeout,
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
- disconnect() {
61
- if(!this.instance) {
62
- this.log('No Paho instance');
63
- return this.promise = Promise.resolve(this.instance);
64
- }
65
- if(!this.instance.isConnected()) {
66
- this.log('Paho instance not connected');
67
- return this.promise = Promise.resolve(this.instance);
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
- return new Promise((resolve) => {
71
- let ___ = () => {
72
- this.promise = Promise.resolve(this.instance);
73
- this.off('error', ___);
74
- this.off('disconnected', ___);
75
- resolve(this.instance);
76
- };
77
- this.on('error', ___);
78
- this.on('disconnected', ___);
79
- try {
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.instance && this.instance.isConnected();
124
+ return this.connectionActive;
89
125
  }
90
126
 
91
127
  subscribe(topic) {
92
- return this.instance && this.instance.isConnected() && this.instance.subscribe(topic);
128
+ return this.device && this.device.subscribe(topic);
93
129
  }
94
130
 
95
131
  unsubscribe(topic) {
96
- return this.instance && this.instance.isConnected() && this.instance.unsubscribe(topic);
132
+ return this.device && this.device.unsubscribe(topic);
97
133
  }
98
134
 
99
135
  send(topic, message) {
100
- let msg = new Paho.Message(typeof message === 'object' ? JSON.stringify(message) : message);
101
- msg.destinationName = topic;
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.emit('connected');
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.emit('disconnected', responseObject.errorCode !== 0);
151
+ this.connectionActive = false;
152
+ this.emit('close');
113
153
  }
114
- __messageCb(message) {
154
+ __offlineCb(responseObject) {
155
+ this.emit('offline');
156
+ }
157
+
158
+ __messageCb(t, message, packet) {
115
159
 
116
- const payload = JSON.parse(message.payloadString);
117
- const topic = message.destinationName.split('/');
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 === "externalmix_changed"
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
  }
@@ -6,87 +6,32 @@ import {generateUUID} from "./wt-utils";
6
6
 
7
7
  class Room {
8
8
 
9
- constructor(enableDebugFlag) {
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
- this.initialized = false;
16
- this.log = Room.noop;
17
- this.enableDebugFlag = enableDebugFlag;
18
- if (enableDebugFlag) {
19
- this.enableDebug();
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.isReady = this.initialize();
25
+ this.whenInitialized = this.initialize();
24
26
  }
25
27
 
26
28
  initialize() {
27
- return new Promise((resolve, reject) => {
28
- if (this.initialized) {
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
- 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,12 +102,7 @@ class RoomSession {
164
102
  }
165
103
  };
166
104
 
167
- constructor(enableDebugFlag, type = 'reactooroom', options = {
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 = options;
186
- //this.pluginName = this.#sessionTypes[type];
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 = Room.randomString(16);
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 (enableDebugFlag) {
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 instructor and talkback
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 instructor and talkback
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 -> Im observer and im not instructor and user connecting is not talkback
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(e => null)
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
- //TODO: find a better way
783
- if (!this.disconnectingPromise) {
784
- this._log('silent data event error')
785
- this.emit('error', {
786
- type: this.handleId === handleId ? 'error' : 'warning',
787
- id: 9,
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((r) => {
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(dontWaitForResponses = false) {
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(dontWaitForResponses = false) {
1120
+ destroy() {
1187
1121
 
1188
1122
  if (this.sessiontype === 'reactooroom') {
1189
- return this.disconnect(dontWaitForResponses)
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(dontWaitForResponses)
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 && adapter.browserDetails.browser === 'safari') {
1938
+ if(this.options.safariBugHotfixEnabled) {
2005
1939
  this.isVideoMuted = !this.isVideoMuted;
2006
1940
  }
2007
1941
  else if (this.isUnifiedPlan) {
@@ -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
  ]