@reactoo/watchtogether-sdk-js 2.5.6 → 2.5.10
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 +204 -928
- package/dist/watchtogether-sdk.min.js +2 -2
- package/example/bulk_join_room/bulk_join_room.html +0 -5
- package/package.json +3 -4
- package/src/models/auth.js +1 -2
- package/src/models/room-session.js +10 -13
- package/src/modules/wt-room.js +9 -11
- package/src/modules/wt-utils.js +13 -19
|
@@ -70,11 +70,6 @@
|
|
|
70
70
|
document.getElementById('join-room').setAttribute('disabled', true);
|
|
71
71
|
document.getElementById('joined-participants-count').value = joinedParticipantsCount;
|
|
72
72
|
|
|
73
|
-
// // TODO - toto tu na konci nebude. Je to len preistotu, aby som znova nezhodil server
|
|
74
|
-
// if (participantsCount > 4) {
|
|
75
|
-
// participantsCount = 4;
|
|
76
|
-
// }
|
|
77
|
-
|
|
78
73
|
participantsData = Array(participantsCount).fill(0).map((_, i) => {
|
|
79
74
|
const canvas = document.createElement('canvas');
|
|
80
75
|
const canvasContext = canvas.getContext('2d');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactoo/watchtogether-sdk-js",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.10",
|
|
4
4
|
"description": "Javascript SDK for Reactoo",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"unpkg": "dist/watchtogether-sdk.min.js",
|
|
@@ -42,10 +42,9 @@
|
|
|
42
42
|
"yargs": "^10.1.2"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@fingerprintjs/fingerprintjs": "^
|
|
45
|
+
"@fingerprintjs/fingerprintjs": "^3.3.2",
|
|
46
46
|
"aws-iot-device-sdk": "^2.2.11",
|
|
47
|
-
"
|
|
48
|
-
"serialize-error": "^7.0.1",
|
|
47
|
+
"serialize-error": "^9.1.0",
|
|
49
48
|
"swagger-client": "^3.18.0",
|
|
50
49
|
"webrtc-adapter": "^8.1.1"
|
|
51
50
|
},
|
package/src/models/auth.js
CHANGED
|
@@ -34,8 +34,7 @@ let auth = function () {
|
|
|
34
34
|
},
|
|
35
35
|
|
|
36
36
|
deviceLogin: (salt) => {
|
|
37
|
-
return
|
|
38
|
-
.then(() => getBrowserFingerprint(this.__instanceType, salt))
|
|
37
|
+
return getBrowserFingerprint(this.__instanceType, salt)
|
|
39
38
|
.then( deviceId => Promise.all([deviceId, this.__privates.auth.__client]))
|
|
40
39
|
.then(([deviceId, client]) => client.apis.auth.deviceSignIn({},{requestBody:{deviceId, domain: location.hostname}}))
|
|
41
40
|
.then(response => {
|
|
@@ -19,6 +19,7 @@ import syncUniversal from "../modules/sync-modules/sync-universal";
|
|
|
19
19
|
|
|
20
20
|
let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructor}, room, wt) {
|
|
21
21
|
|
|
22
|
+
let primaryRoomId = roomId;
|
|
22
23
|
let publicCustomEvents = ['changePlayerSource', 'chatMessage', 'userUpdate', 'reconnecting', 'connecting', 'remoteMuted', 'scaling'];
|
|
23
24
|
|
|
24
25
|
const addEvents = (events) => {
|
|
@@ -34,13 +35,13 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
34
35
|
|
|
35
36
|
room.on('addLocalParticipant', () => {
|
|
36
37
|
|
|
37
|
-
// TODO: this
|
|
38
|
+
// TODO: this doesnt seem to be fixable until we switch to differen type of messaging
|
|
38
39
|
// At some random case we don't get message back if we don't wait
|
|
39
40
|
|
|
40
41
|
clearTimeout(alpTimeoutId);
|
|
41
42
|
alpTimeoutId = setTimeout(() => {
|
|
42
43
|
___.__requestMuteStatus();
|
|
43
|
-
},
|
|
44
|
+
}, 2000);
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
room.on('localMuted', ({type, value}) => {
|
|
@@ -82,11 +83,11 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
82
83
|
return room._iceRestart(room.handleId);
|
|
83
84
|
},
|
|
84
85
|
|
|
85
|
-
connect: function () {
|
|
86
|
+
connect: function ({reactooRoomId = null} = {}) {
|
|
86
87
|
emitter.emit('connecting', true);
|
|
87
88
|
clearTimeout(alpTimeoutId);
|
|
88
89
|
return Promise.all([wt.room.__joinRoom({
|
|
89
|
-
roomId,
|
|
90
|
+
roomId: reactooRoomId || primaryRoomId,
|
|
90
91
|
pinHash,
|
|
91
92
|
isTalkback,
|
|
92
93
|
isMonitor,
|
|
@@ -94,16 +95,14 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
94
95
|
}), wt.user.getUserSelf()])
|
|
95
96
|
.then(([roomData, userData]) => {
|
|
96
97
|
// Happens when we reroute user to a different room
|
|
97
|
-
if(roomData?.data?.reactooRoomId) {
|
|
98
|
-
roomId = roomData.data.reactooRoomId
|
|
98
|
+
if(roomData?.data?.reactooRoomId !== roomId) {
|
|
99
|
+
roomId = roomData.data.reactooRoomId;
|
|
100
|
+
emitter.emit('changeRoomId', roomId);
|
|
99
101
|
}
|
|
100
102
|
return Promise.all([roomData, userData])
|
|
101
103
|
})
|
|
102
104
|
.then(([roomData, userData]) => Promise.all([roomData, userData, this.setRoomVars()]))
|
|
103
105
|
.then(([roomData, userData, _]) => Promise.all([roomData, userData, room.connect(roomData.data.roomId, roomData.data.pin, roomData.data.href, roomData.data.iceServers, roomData.data.accessToken, (isMonitor || isInstructor || isTalkback) ? roomData.data.userId : userData.data._id, roomData.data.webrtcVersion, (roomData.data.bitrate ? parseInt(roomData.data.bitrate) : 0), isMonitor, roomData.data.recordingFilename)]))
|
|
104
|
-
.then(([roomData, userData, _]) => {
|
|
105
|
-
return roomData.data
|
|
106
|
-
})
|
|
107
106
|
.finally(() => {
|
|
108
107
|
emitter.emit('connecting', false);
|
|
109
108
|
})
|
|
@@ -116,7 +115,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
116
115
|
},
|
|
117
116
|
|
|
118
117
|
//TODO: refactor restart method
|
|
119
|
-
restart: function (isObserver = false) {
|
|
118
|
+
restart: function ({isObserver = false, reactooRoomId = null} = {}) {
|
|
120
119
|
|
|
121
120
|
emitter.emit('reconnecting', true);
|
|
122
121
|
room.isRestarting = true;
|
|
@@ -130,7 +129,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
130
129
|
|
|
131
130
|
return this.disconnect()
|
|
132
131
|
.then(() => wait(1000)) //TODO: remove 1000ms wait by waiting for proper events from janus
|
|
133
|
-
.then(() => this.connect())
|
|
132
|
+
.then(() => this.connect({reactooRoomId}))
|
|
134
133
|
.then(() => {
|
|
135
134
|
if (isObserver) {
|
|
136
135
|
return this.publishLocal(null, {getStreamIfEmpty: false, unpublishFirst: true});
|
|
@@ -171,7 +170,6 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
171
170
|
} else if (msg.action === 'user_update_displayname' || msg.action === 'user_update_avatar' || msg.action === 'user_update_customattributes' || msg.action === 'user_update_privateattributes') {
|
|
172
171
|
emitter.emit('userUpdate', msg.text);
|
|
173
172
|
} else if (msg.action === 'observer_connecting' || msg.action === 'talkback_connecting' || msg.action === 'instructor_connecting') {
|
|
174
|
-
|
|
175
173
|
this.setRoomVars(null, msg.action === 'observer_connecting').catch(e => {
|
|
176
174
|
room._log('Setting observers failed, this will cause issues', e);
|
|
177
175
|
});
|
|
@@ -291,7 +289,6 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
291
289
|
setRoomVars: (observerIds = [], emit = true) => {
|
|
292
290
|
return wt.room.getRoomById(roomId, pinHash)
|
|
293
291
|
.then(r => {
|
|
294
|
-
|
|
295
292
|
if (emit) {
|
|
296
293
|
// emiting "fake" playerSource event
|
|
297
294
|
//TODO: somehow push into sync modules instead
|
package/src/modules/wt-room.js
CHANGED
|
@@ -12,10 +12,8 @@ class Room {
|
|
|
12
12
|
this.safariVp8 = false;
|
|
13
13
|
this.browser = adapter.browserDetails.browser;
|
|
14
14
|
this.browserDetails = adapter.browserDetails;
|
|
15
|
-
|
|
16
|
-
this.isWebrtcSupported = Room.isWebrtcSupported();
|
|
15
|
+
this.webrtcSupported = Room.isWebrtcSupported();
|
|
17
16
|
this.safariVp8TestPromise = Room.testSafariVp8();
|
|
18
|
-
|
|
19
17
|
this.safariVp8 = null;
|
|
20
18
|
this.safariVp8TestPromise.then(safariVp8 => {
|
|
21
19
|
this.safariVp8 = safariVp8;
|
|
@@ -103,6 +101,9 @@ class RoomSession {
|
|
|
103
101
|
};
|
|
104
102
|
|
|
105
103
|
constructor(constructId = null, type = 'reactooroom', debug, options = {}) {
|
|
104
|
+
|
|
105
|
+
Object.assign(this, emitter());
|
|
106
|
+
|
|
106
107
|
this.server = null;
|
|
107
108
|
this.iceServers = null;
|
|
108
109
|
this.token = null;
|
|
@@ -124,18 +125,15 @@ class RoomSession {
|
|
|
124
125
|
},
|
|
125
126
|
options
|
|
126
127
|
};
|
|
127
|
-
|
|
128
|
-
Object.assign(this, emitter());
|
|
129
|
-
|
|
130
128
|
this.id = null;
|
|
131
129
|
this.privateId = null;
|
|
132
|
-
|
|
133
130
|
this.constructId = constructId || RoomSession.randomString(16);
|
|
134
131
|
this.sessionId = null;
|
|
135
132
|
this.handleId = null;
|
|
136
133
|
this.ws = null;
|
|
137
134
|
this.isRestarting = false;
|
|
138
|
-
|
|
135
|
+
|
|
136
|
+
//TODO: do it better
|
|
139
137
|
// double click prevention
|
|
140
138
|
this.connectingPromise = null;
|
|
141
139
|
this.disconnectingPromise = null;
|
|
@@ -152,14 +150,11 @@ class RoomSession {
|
|
|
152
150
|
this._isStreaming = false;
|
|
153
151
|
this._isPublished = false;
|
|
154
152
|
this._isDataChannelOpen = false;
|
|
155
|
-
|
|
156
153
|
this.isAudioMuted = false;
|
|
157
154
|
this.isVideoMuted = false;
|
|
158
155
|
this.isVideoEnabled = false;
|
|
159
156
|
this.isAudioEnabed = false;
|
|
160
|
-
|
|
161
157
|
this.isUnifiedPlan = RoomSession.checkUnifiedPlan();
|
|
162
|
-
|
|
163
158
|
this._log = RoomSession.noop;
|
|
164
159
|
if (this.options.debug) {
|
|
165
160
|
this._enableDebug();
|
|
@@ -682,6 +677,7 @@ class RoomSession {
|
|
|
682
677
|
track: null,
|
|
683
678
|
adding: false,
|
|
684
679
|
constructId: this.constructId,
|
|
680
|
+
metaData: this.options.metaData,
|
|
685
681
|
hasAudioTrack: false,
|
|
686
682
|
hasVideoTrack: false
|
|
687
683
|
});
|
|
@@ -1271,6 +1267,7 @@ class RoomSession {
|
|
|
1271
1267
|
stream: config.stream,
|
|
1272
1268
|
track: event.track,
|
|
1273
1269
|
constructId: this.constructId,
|
|
1270
|
+
metaData: this.options.metaData,
|
|
1274
1271
|
adding: true,
|
|
1275
1272
|
hasAudioTrack: !!(config.stream && config.stream.getAudioTracks().length),
|
|
1276
1273
|
hasVideoTrack: !!(config.stream && config.stream.getVideoTracks().length)
|
|
@@ -1305,6 +1302,7 @@ class RoomSession {
|
|
|
1305
1302
|
stream: config.stream,
|
|
1306
1303
|
track: ev.target,
|
|
1307
1304
|
constructId: this.constructId,
|
|
1305
|
+
metaData: this.options.metaData,
|
|
1308
1306
|
adding: false,
|
|
1309
1307
|
hasAudioTrack: !!(config.stream && config.stream.getAudioTracks().length),
|
|
1310
1308
|
hasVideoTrack: !!(config.stream && config.stream.getVideoTracks().length)
|
package/src/modules/wt-utils.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import FingerprintJs from "@fingerprintjs/fingerprintjs";
|
|
2
2
|
|
|
3
3
|
let wait = function(ms) { return new Promise(resolve => setTimeout(resolve, ms))};
|
|
4
|
-
|
|
4
|
+
let fingerprint = FingerprintJs.load({
|
|
5
|
+
monitoring: false
|
|
6
|
+
})
|
|
5
7
|
let getBrowserFingerprint = function (instanceType = '', salt = '') {
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
new Fingerprint2.get(options, (components) => {
|
|
18
|
-
var values = components.map(function (component) { return component.value });
|
|
19
|
-
var murmur = Fingerprint2.x64hash128(values.join(''), 31);
|
|
20
|
-
resolve([8,13,18,23].reduce((acc, cur) => {
|
|
8
|
+
return fingerprint
|
|
9
|
+
.then(fp => fp.get())
|
|
10
|
+
.then(result => {
|
|
11
|
+
const components = {
|
|
12
|
+
...result.components,
|
|
13
|
+
instanceType: { value: instanceType + '_' + salt },
|
|
14
|
+
}
|
|
15
|
+
return [8,13,18,23].reduce((acc, cur) => {
|
|
21
16
|
return acc.slice(0,cur) + '-' + acc.slice(cur)
|
|
22
|
-
},
|
|
17
|
+
}, FingerprintJs.hashComponents(components)).substring(0,36)
|
|
23
18
|
})
|
|
24
|
-
});
|
|
25
19
|
};
|
|
26
20
|
|
|
27
21
|
let generateUUID = function () {
|