@reactoo/watchtogether-sdk-js 2.8.43 → 2.8.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.8.43",
3
+ "version": "2.8.44",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "dist/watchtogether-sdk.min.js",
6
6
  "module": "dist/watchtogether-sdk.min.js",
@@ -956,12 +956,14 @@ class RoomSession {
956
956
  if(label === null) {
957
957
  Object.keys(this.#publisherHandle.webrtcStuff.dataChannel).forEach((key) => {
958
958
  const channel = this.#publisherHandle.webrtcStuff.dataChannel[key];
959
- channel.send(JSON.stringify(data));
959
+ if(channel && channel.readyState === 'open') {
960
+ channel.send(JSON.stringify(data));
961
+ }
960
962
  })
961
963
  }
962
964
  else {
963
965
  const channel = this.#publisherHandle.webrtcStuff.dataChannel[label];
964
- if(channel) {
966
+ if(channel && channel.readyState === 'open') {
965
967
  channel.send(JSON.stringify(data));
966
968
  }
967
969
  }
@@ -1437,8 +1439,8 @@ class RoomSession {
1437
1439
  .catch((e) => {
1438
1440
  this._log(e);
1439
1441
  });
1440
- this.#emitRemoteFeedUpdate(null, {feedRemoval: true, attendee: {id:leaving}});
1441
- this.#removeAttendeeFromCache(leaving);
1442
+ this.#emitRemoteFeedUpdate(null, {feedRemoval: true, attendee: {id:kicked}});
1443
+ this.#removeAttendeeFromCache(kicked);
1442
1444
  }
1443
1445
 
1444
1446
  if(joining) {
@@ -1614,7 +1616,7 @@ class RoomSession {
1614
1616
  transceiverMap: [], // got from msg["streams"]
1615
1617
  streamMap: {}, // id to sources to mids?
1616
1618
  availablePublishers: [],
1617
- subscribeMap: [], // subscribed to [id][mid]
1619
+ subscribeMap: {}, // subscribed to [id][mid]
1618
1620
  stats: {},
1619
1621
  currentLayers : new Map(),
1620
1622
  qualityHistory : new Map(),
@@ -1725,7 +1727,7 @@ class RoomSession {
1725
1727
  transceiverMap: [], // got from msg["streams"]
1726
1728
  streamMap: {}, // id to sources to mids?
1727
1729
  availablePublishers: [],
1728
- subscribeMap: [], // subscribed to [id][mid]
1730
+ subscribeMap: {}, // subscribed to [id][mid]
1729
1731
  stats: {},
1730
1732
  currentLayers : new Map(),
1731
1733
  qualityHistory : new Map(),
@@ -1912,6 +1914,7 @@ class RoomSession {
1912
1914
  };
1913
1915
 
1914
1916
  this.ws.onerror = (e) => {
1917
+ this.isEstablishingConnection = false
1915
1918
  this._abortController.signal.removeEventListener('abort', abortConnect);
1916
1919
  reject({type: 'error', id: 18, message: 'ws connection error', data: e});
1917
1920
  }
@@ -2357,6 +2360,10 @@ class RoomSession {
2357
2360
  this._log('onconnectionstatechange: connectionState === failed');
2358
2361
  this.#iceRestart(handleId);
2359
2362
  }
2363
+ if (config.pc.connectionState === 'disconnected') {
2364
+ this._log('onconnectionstatechange: connectionState === disconnected');
2365
+ // TODO: keyframe request?
2366
+ }
2360
2367
  this.emit('connectionState', [handleId, handleId === this.#publisherHandle?.handleId, config.pc.connectionState]);
2361
2368
  };
2362
2369
 
@@ -2365,6 +2372,10 @@ class RoomSession {
2365
2372
  this._log('oniceconnectionstatechange: iceConnectionState === failed');
2366
2373
  this.#iceRestart(handleId);
2367
2374
  }
2375
+ if (config.pc.connectionState === 'disconnected') {
2376
+ this._log('oniceconnectionstatechange: connectionState === disconnected');
2377
+ // TODO: keyframe request?
2378
+ }
2368
2379
  this.emit('iceState', [handleId, handleId === this.#publisherHandle?.handleId, config.pc.iceConnectionState]);
2369
2380
  };
2370
2381
 
@@ -2421,9 +2432,9 @@ class RoomSession {
2421
2432
 
2422
2433
  let mid = transceiver?.mid || ev.track.id;
2423
2434
 
2424
- // transceiver may not exist already
2425
- if(mid === ev.target.id && config.mids?.[event.track.id]) {
2426
- mid = config.mids[event.track.id];
2435
+ // Use the removed track’s id, not the outer ontrack event’s
2436
+ if (mid === ev.track.id && config.mids?.[ev.track.id]) {
2437
+ mid = config.mids[ev.track.id];
2427
2438
  }
2428
2439
 
2429
2440
  this.#emitRemoteFeedUpdate(mid, {
@@ -3200,6 +3211,8 @@ class RoomSession {
3200
3211
  }
3201
3212
  catch(e) {
3202
3213
  this.emit('publishing', false);
3214
+ this.emit('error', e);
3215
+ throw e;
3203
3216
  }
3204
3217
 
3205
3218