@reactoo/watchtogether-sdk-js 2.6.45 → 2.6.47

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.
@@ -285,7 +285,7 @@
285
285
  });
286
286
 
287
287
  session.$on('error', (e) => {
288
- console.log(e);
288
+ console.error(e);
289
289
  if(e && e.type === 'error') {
290
290
  session.disconnect().catch(e => console.log(e));
291
291
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.6.45",
3
+ "version": "2.6.47",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -203,8 +203,8 @@ class RoomSession {
203
203
  this._maxRetries = 5;
204
204
  this._keepAliveId = null;
205
205
  this._participants = [];
206
- this._talkIntercomGroups = [];
207
- this._listenIntercomGroups = [];
206
+ this._talkIntercomGroups = ['all'];
207
+ this._listenIntercomGroups = ['all'];
208
208
  this._roomType = 'watchparty';
209
209
  this._isDataChannelOpen = false;
210
210
  this._abortController = null;
@@ -380,7 +380,7 @@ class RoomSession {
380
380
  messageTimeoutId = setTimeout(() => {
381
381
  this.ws.removeEventListener('message', parseResponse);
382
382
  this._abortController.signal.removeEventListener('abort', abortResponse);
383
- reject({type: 'error', id: 3, message: 'send timeout', data: requestData});
383
+ reject({type: 'warning', id: 3, message: 'send timeout', data: requestData});
384
384
  }, 10000);
385
385
 
386
386
  this._abortController.signal.addEventListener('abort', abortResponse);
@@ -556,6 +556,7 @@ class RoomSession {
556
556
  "room": this.roomId,
557
557
  "ptype": "subscriber",
558
558
  "private_id": this.privateId,
559
+ //TODO: check which groups we want to subscribe to
559
560
  streams: streams.filter(s => !s.disabled).map(stream => ({feed: stream.id, mid: stream.mid})),
560
561
  //"feed": id,
561
562
  ...(this.webrtcVersion > 1000 ? {id: this.userId} : {}),
@@ -590,15 +591,17 @@ class RoomSession {
590
591
  let handle = this._getHandle(null, id);
591
592
  if(handle) {
592
593
 
593
- //description: 'camera0'
594
+ //TODO: check which groups we want to subscribe to
594
595
  const _sfn = (stream) => {
595
596
  if(stream.type === 'data') {
596
597
  return true;
597
598
  }
599
+ // if stream.description is not set, we assume it's a data stream, and we shouldn't get here at all
600
+ const source = stream.description ? JSON.parse(stream.description)?.source : undefined;
598
601
  if(!this.options?.restrictSources?.length) {
599
602
  return true
600
603
  }
601
- else if(this.options?.restrictSources?.includes(stream.description)) {
604
+ else if(this.options?.restrictSources?.includes(source)) {
602
605
  return true;
603
606
  }
604
607
  return false;
@@ -627,6 +630,7 @@ class RoomSession {
627
630
  "room": this.roomId,
628
631
  "ptype": "subscriber",
629
632
  "private_id": this.privateId,
633
+ //TODO: check which groups we want to subscribe to
630
634
  streams: streams.filter(s => !s.disabled).map(stream => ({feed: stream.id, mid: stream.mid})),
631
635
  ...(this.webrtcVersion > 1000 ? {id: this.userId} : {}),
632
636
  pin: this.pin
@@ -941,7 +945,6 @@ class RoomSession {
941
945
  dtmfSender: null,
942
946
  trickle: true,
943
947
  iceDone: false,
944
- isIceRestarting: false
945
948
  }
946
949
  };
947
950
  this._participants.push(handle);
@@ -986,12 +989,15 @@ class RoomSession {
986
989
  if(tItem.active === false) {
987
990
  return;
988
991
  }
989
- if(!config.streamMap[tItem.feed_description]) {
990
- config.streamMap[tItem.feed_description] = [];
992
+
993
+ const source = JSON.parse(tItem.feed_description)?.source;
994
+
995
+ if(!config.streamMap[source]) {
996
+ config.streamMap[source] = [];
991
997
  }
992
998
  let trackId = config.pc.getTransceivers().find(t => t.mid === tItem.mid).receiver.track.id;
993
999
  if(trackId) {
994
- config.streamMap[tItem.feed_description].push(trackId);
1000
+ config.streamMap[source].push(trackId);
995
1001
  }
996
1002
  })
997
1003
  }
@@ -1397,9 +1403,9 @@ class RoomSession {
1397
1403
  };
1398
1404
 
1399
1405
  config.pc.onconnectionstatechange = () => {
1400
- //TODO: check if this isnt fired prematurely when we switch internet connection
1401
1406
  if (config.pc.connectionState === 'failed') {
1402
1407
  this._log('connectionState failed');
1408
+ this._iceRestart(handleId);
1403
1409
  }
1404
1410
  this.emit('connectionState', [handleId, handleId === this.handleId, config.pc.connectionState]);
1405
1411
  if(handleId !== this.handleId && config.pc.connectionState === 'connected') {
@@ -1694,14 +1700,13 @@ class RoomSession {
1694
1700
  }
1695
1701
  var config = handle.webrtcStuff;
1696
1702
 
1697
- // Already restarting;
1698
- if (config.isIceRestarting) {
1703
+ if(config.pc.signalingState === 'stable') {
1704
+ this._log('ICE restart not needed');
1699
1705
  return;
1700
1706
  }
1701
1707
 
1702
1708
  if (this.handleId === handleId) {
1703
1709
  this._log('Performing local ICE restart');
1704
- config.isIceRestarting = true;
1705
1710
  let hasAudio = !!(config.stream && config.stream.getAudioTracks().length > 0);
1706
1711
  let hasVideo = !!(config.stream && config.stream.getVideoTracks().length > 0);
1707
1712
  this._createAO('offer', handleId, true )
@@ -1715,23 +1720,17 @@ class RoomSession {
1715
1720
  });
1716
1721
  })
1717
1722
  .then(r => {
1718
- config.isIceRestarting = false;
1719
1723
  this._log('ICE restart success');
1720
1724
  })
1721
1725
  .catch((e) => {
1722
- config.isIceRestarting = false;
1723
1726
  this.emit('error', {type: 'warning', id: 28, message: 'iceRestart failed', data: e});
1724
1727
  });
1725
1728
  } else {
1726
1729
  this._log('Performing remote ICE restart', handleId);
1727
- config.isIceRestarting = true;
1728
1730
  return this.sendMessage(handleId, {
1729
1731
  body: {"request": "configure", "restart": true}
1730
1732
  }).then(() => {
1731
- config.isIceRestarting = false;
1732
- }).catch(() => {
1733
- config.isIceRestarting = false;
1734
- });
1733
+ }).catch(() => {});
1735
1734
  }
1736
1735
 
1737
1736
  }
@@ -2269,7 +2268,7 @@ class RoomSession {
2269
2268
  config.streamMap[source].forEach(trackId => {
2270
2269
  let t = transceivers.find(transceiver => transceiver.sender.track && transceiver.sender.track.id === trackId)
2271
2270
  if(t) {
2272
- descriptions.push({mid: t.mid, description: source});
2271
+ descriptions.push({mid: t.mid, description: JSON.stringify({source, intercomGroups: this._talkIntercomGroups})});
2273
2272
  }
2274
2273
  })
2275
2274
  });
@@ -2424,7 +2423,7 @@ class RoomSession {
2424
2423
  }
2425
2424
 
2426
2425
 
2427
- setTalkIntercomGroups(groups = []) {
2426
+ setTalkIntercomGroups(groups = ['all']) {
2428
2427
  this._talkIntercomGroups = structuredClone(groups);
2429
2428
  let handle = this._getHandle(this.handleId);
2430
2429
  if (!handle) {
@@ -2441,8 +2440,6 @@ class RoomSession {
2441
2440
  }
2442
2441
  })
2443
2442
  });
2444
- //TODO: under development
2445
- return Promise.resolve();
2446
2443
  return this.sendMessage(this.handleId, {
2447
2444
  body: {
2448
2445
  "request": "configure",
@@ -2451,7 +2448,7 @@ class RoomSession {
2451
2448
  })
2452
2449
  }
2453
2450
 
2454
- setListenIntercomGroups(groups = []) {
2451
+ setListenIntercomGroups(groups = ['all']) {
2455
2452
  this._listenIntercomGroups = groups;
2456
2453
  }
2457
2454