@reactoo/watchtogether-sdk-js 2.6.21 → 2.6.23
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/example/index.html
CHANGED
|
@@ -200,7 +200,8 @@
|
|
|
200
200
|
})
|
|
201
201
|
.then(r => Instance.room.createSession({constructId, roomId:r.roomId, pinHash: r.pinHash, role:'participant', options: {
|
|
202
202
|
//subscriptionRules: {participant: {videoWall: [], watchTogether: []}}
|
|
203
|
-
|
|
203
|
+
//restrictSources: ['camera0']
|
|
204
|
+
}})) // pin hash is not needed if you're owner of the room
|
|
204
205
|
.then(session => {
|
|
205
206
|
|
|
206
207
|
session.$on('connecting', (status) => {
|
package/package.json
CHANGED
|
@@ -389,17 +389,6 @@ let roomSession = function ({roomId, pinHash, role}, room, wt) {
|
|
|
389
389
|
}
|
|
390
390
|
},
|
|
391
391
|
|
|
392
|
-
__test: function (value) {
|
|
393
|
-
return room.sendMessage(room.handleId, {
|
|
394
|
-
body: {
|
|
395
|
-
request: "data",
|
|
396
|
-
room: room.roomId,
|
|
397
|
-
timestamp: new Date().getTime(),
|
|
398
|
-
text: JSON.stringify(value),
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
},
|
|
402
|
-
|
|
403
392
|
$on: (key, callback, that) => {
|
|
404
393
|
emitter.on(key, callback, that || this);
|
|
405
394
|
room.on(key, callback, that || this);
|
package/src/modules/wt-room.js
CHANGED
|
@@ -94,7 +94,7 @@ class RoomSession {
|
|
|
94
94
|
'streaming': 'janus.plugin.streaming'
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
static
|
|
97
|
+
static userRoleSubscriptionRules = {
|
|
98
98
|
participant: {
|
|
99
99
|
"watchparty": ['participant', 'talkback'],
|
|
100
100
|
"studio": ['participant', 'talkback', 'host', 'observer'],
|
|
@@ -210,9 +210,9 @@ class RoomSession {
|
|
|
210
210
|
this.isVideoEnabled = false;
|
|
211
211
|
this.isAudioEnabed = false;
|
|
212
212
|
|
|
213
|
-
this.
|
|
214
|
-
...RoomSession.
|
|
215
|
-
...(this.options.
|
|
213
|
+
this.userRoleSubscriptionRules = {
|
|
214
|
+
...RoomSession.userRoleSubscriptionRules,
|
|
215
|
+
...(this.options.userRoleSubscriptionRules || {})
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
this._log = RoomSession.noop;
|
|
@@ -226,7 +226,7 @@ class RoomSession {
|
|
|
226
226
|
const remoteUser = decodeJanusDisplay(userId);
|
|
227
227
|
let localUserRole = myUser?.role || 'participant';
|
|
228
228
|
let remoteUserRole = remoteUser?.role || 'participant';
|
|
229
|
-
return this.
|
|
229
|
+
return this.userRoleSubscriptionRules[localUserRole][(this._roomType || 'watchparty')].indexOf(remoteUserRole) > -1;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
_getAddParticipantEventName(handleId) {
|
|
@@ -572,7 +572,22 @@ class RoomSession {
|
|
|
572
572
|
|
|
573
573
|
let handle = this._getHandle(null, id);
|
|
574
574
|
if(handle) {
|
|
575
|
-
|
|
575
|
+
|
|
576
|
+
//description: 'camera0'
|
|
577
|
+
const _sfn = (stream) => {
|
|
578
|
+
if(stream.type === 'data') {
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
581
|
+
if(!this.options?.restrictSources?.length) {
|
|
582
|
+
return true
|
|
583
|
+
}
|
|
584
|
+
else if(this.options?.restrictSources?.includes(stream.description)) {
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
return false;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
let subscribe = streams.filter(stream => !stream.disabled && _sfn(stream) && handle.webrtcStuff.tracksMap.filter(t => t.active).findIndex(t => t.mid === stream.mid) === -1).map(s => ({feed: s.id, mid: s.mid}));
|
|
576
591
|
let unsubscribe = streams.filter(stream => stream.disabled).map(s => ({feed: s.id, mid: s.mid}));
|
|
577
592
|
this._log('Already subscribed to user: ', userId, 'Update streams', subscribe, unsubscribe);
|
|
578
593
|
if(subscribe.length || unsubscribe.length) {
|