@reactoo/watchtogether-sdk-js 2.4.43 → 2.5.3

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 +1852 -2392
  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 +2 -2
  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 +29 -11
  42. package/src/models/room.js +138 -97
  43. package/src/models/system.js +45 -0
  44. package/src/models/user.js +6 -3
  45. package/src/modules/wt-iot.js +124 -74
  46. package/src/modules/wt-room.js +60 -125
  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
- });
29
+ return this.safariVp8TestPromise
30
+ .then(() => this);
44
31
  }
45
32
 
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();
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(enableDebugFlag, type = 'reactooroom', options = {}) {
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 = Room.randomString(16);
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 (enableDebugFlag) {
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,
@@ -475,7 +412,7 @@ class RoomSession {
475
412
  let subCondition = false
476
413
 
477
414
  if(!isClassroom) {
478
- subscribeCondition = allowedObservers.indexOf(userId) === -1 && allowedTalkback.indexOf(this.userId) === -1;
415
+ subscribeCondition = allowedObservers.indexOf(userId) === -1 && allowedTalkback.indexOf(this.userId) === -1;
479
416
  } else {
480
417
 
481
418
  // instructor -> everyone but observer
@@ -488,7 +425,7 @@ class RoomSession {
488
425
  /*
489
426
 
490
427
  monitor/talkback -> all but talkback
491
- observer -> all but instructor and talkback
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 instructor and talkback
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 -> 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
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(e => null)
651
+ }).catch(() => null)
715
652
  }
716
653
  }
717
654
  }
@@ -744,6 +681,7 @@ class RoomSession {
744
681
  stream: null,
745
682
  track: null,
746
683
  adding: false,
684
+ constructId: this.constructId,
747
685
  hasAudioTrack: false,
748
686
  hasVideoTrack: false
749
687
  });
@@ -780,17 +718,13 @@ class RoomSession {
780
718
  }
781
719
 
782
720
  if (type === 'error') {
783
-
784
- //TODO: find a better way
785
- if (!this.disconnectingPromise) {
786
- this._log('silent data event error')
787
- this.emit('error', {
788
- type: this.handleId === handleId ? 'error' : 'warning',
789
- id: 9,
790
- message: 'data event error',
791
- data: [handleId, data]
792
- });
793
- }
721
+
722
+ this.emit('error', {
723
+ type: 'warning',
724
+ id: 9,
725
+ message: 'data event warning',
726
+ data: [handleId, data]
727
+ });
794
728
 
795
729
  if (handle) {
796
730
  let config = handle.webrtcStuff;
@@ -819,7 +753,6 @@ class RoomSession {
819
753
 
820
754
  //removeHandle === true -> hangup, detach, removeHandle === false -> hangup
821
755
  _removeParticipant(handleId, rfid, removeHandle = true) {
822
-
823
756
  let handle = this._getHandle(handleId, rfid);
824
757
 
825
758
  if (!handle) {
@@ -858,7 +791,7 @@ class RoomSession {
858
791
  try {
859
792
  handle.webrtcStuff.pc.close();
860
793
  } catch (e) {
861
-
794
+
862
795
  }
863
796
  handle.webrtcStuff = {
864
797
  stream: null,
@@ -872,11 +805,6 @@ class RoomSession {
872
805
  iceDone: false,
873
806
  };
874
807
 
875
- if (removeHandle) {
876
- let handleIndex = this._participants.findIndex(p => p.handleId === handleId);
877
- this._participants.splice(handleIndex, 1);
878
- }
879
-
880
808
  if (handleId === this.handleId) {
881
809
  this._isDataChannelOpen = false;
882
810
  this._isPublished = false;
@@ -898,6 +826,11 @@ class RoomSession {
898
826
  }
899
827
  this.emit(eventName, {id: handleId, userId: handle.userId});
900
828
  }
829
+
830
+ if (removeHandle) {
831
+ let handleIndex = this._participants.findIndex(p => p.handleId === handleId);
832
+ this._participants.splice(handleIndex, 1);
833
+ }
901
834
 
902
835
  return true;
903
836
  });
@@ -950,7 +883,7 @@ class RoomSession {
950
883
  _leaveRoom(dontWait = false) {
951
884
  return this._hasJoined
952
885
  ? this.sendMessage(this.handleId, {body: {"request": "leave"}}, dontWait)
953
- .finally((r) => {
886
+ .finally(() => {
954
887
  this._hasJoined = false;
955
888
  this.emit('joined', false);
956
889
  })
@@ -1070,7 +1003,7 @@ class RoomSession {
1070
1003
  return this.connectingPromise;
1071
1004
  }
1072
1005
 
1073
- disconnect(dontWaitForResponses = false) {
1006
+ disconnect() {
1074
1007
  if (this.disconnectingPromise) {
1075
1008
  return this.disconnectingPromise;
1076
1009
  }
@@ -1079,8 +1012,8 @@ class RoomSession {
1079
1012
  this.disconnectingPromise = Promise.all(this._participants.map(p => this._removeParticipant(p.handleId)))
1080
1013
  .finally(() => {
1081
1014
  this._wipeListeners();
1082
- this._send({"janus": "destroy"}, true);
1083
1015
  if (this.ws && this.ws.readyState === 1) {
1016
+ this._send({"janus": "destroy"}, true);
1084
1017
  this.ws.close();
1085
1018
  }
1086
1019
  this.sessionId = null;
@@ -1185,16 +1118,16 @@ class RoomSession {
1185
1118
  }
1186
1119
 
1187
1120
 
1188
- destroy(dontWaitForResponses = false) {
1121
+ destroy() {
1189
1122
 
1190
1123
  if (this.sessiontype === 'reactooroom') {
1191
- return this.disconnect(dontWaitForResponses)
1124
+ return this.disconnect()
1192
1125
  .then(() => {
1193
1126
  this.clear();
1194
1127
  return true;
1195
1128
  });
1196
1129
  } else if (this.sessiontype === 'streaming') {
1197
- return this.stopStream(dontWaitForResponses)
1130
+ return this.stopStream()
1198
1131
  .then(() => {
1199
1132
  this.clear();
1200
1133
  return true
@@ -1337,6 +1270,7 @@ class RoomSession {
1337
1270
  userId: handle.userId,
1338
1271
  stream: config.stream,
1339
1272
  track: event.track,
1273
+ constructId: this.constructId,
1340
1274
  adding: true,
1341
1275
  hasAudioTrack: !!(config.stream && config.stream.getAudioTracks().length),
1342
1276
  hasVideoTrack: !!(config.stream && config.stream.getVideoTracks().length)
@@ -1370,6 +1304,7 @@ class RoomSession {
1370
1304
  userId: handle.userId,
1371
1305
  stream: config.stream,
1372
1306
  track: ev.target,
1307
+ constructId: this.constructId,
1373
1308
  adding: false,
1374
1309
  hasAudioTrack: !!(config.stream && config.stream.getAudioTracks().length),
1375
1310
  hasVideoTrack: !!(config.stream && config.stream.getVideoTracks().length)
@@ -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
  ]