livekit-client 1.15.7 → 1.15.9

Sign up to get free protection for your applications and to get access to all the features.
package/src/room/Room.ts CHANGED
@@ -772,6 +772,30 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
772
772
  // @ts-expect-error function is private
773
773
  await this.engine.client.handleOnClose('simulate resume-disconnect');
774
774
  break;
775
+ case 'disconnect-signal-on-resume':
776
+ postAction = async () => {
777
+ // @ts-expect-error function is private
778
+ await this.engine.client.handleOnClose('simulate resume-disconnect');
779
+ };
780
+ req = new SimulateScenario({
781
+ scenario: {
782
+ case: 'disconnectSignalOnResume',
783
+ value: true,
784
+ },
785
+ });
786
+ break;
787
+ case 'disconnect-signal-on-resume-no-messages':
788
+ postAction = async () => {
789
+ // @ts-expect-error function is private
790
+ await this.engine.client.handleOnClose('simulate resume-disconnect');
791
+ };
792
+ req = new SimulateScenario({
793
+ scenario: {
794
+ case: 'disconnectSignalOnResumeNoMessages',
795
+ value: true,
796
+ },
797
+ });
798
+ break;
775
799
  case 'full-reconnect':
776
800
  this.engine.fullReconnectOnNext = true;
777
801
  // @ts-expect-error function is private
@@ -808,11 +832,12 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
808
832
  },
809
833
  });
810
834
  break;
835
+
811
836
  default:
812
837
  }
813
838
  if (req) {
814
- this.engine.client.sendSimulateScenario(req);
815
- postAction();
839
+ await this.engine.client.sendSimulateScenario(req);
840
+ await postAction();
816
841
  }
817
842
  }
818
843
 
@@ -1142,40 +1167,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1142
1167
 
1143
1168
  try {
1144
1169
  // unpublish & republish tracks
1145
- const localPubs: LocalTrackPublication[] = [];
1146
- this.localParticipant.tracks.forEach((pub) => {
1147
- if (pub.track) {
1148
- localPubs.push(pub);
1149
- }
1150
- });
1151
-
1152
- await Promise.all(
1153
- localPubs.map(async (pub) => {
1154
- const track = pub.track!;
1155
- this.localParticipant.unpublishTrack(track, false);
1156
- if (!track.isMuted) {
1157
- if (
1158
- (track instanceof LocalAudioTrack || track instanceof LocalVideoTrack) &&
1159
- track.source !== Track.Source.ScreenShare &&
1160
- track.source !== Track.Source.ScreenShareAudio &&
1161
- !track.isUserProvided
1162
- ) {
1163
- // we need to restart the track before publishing, often a full reconnect
1164
- // is necessary because computer had gone to sleep.
1165
- this.log.debug('restarting existing track', {
1166
- ...this.logContext,
1167
- track: pub.trackSid,
1168
- });
1169
- await track.restartTrack();
1170
- }
1171
- this.log.debug('publishing new track', {
1172
- ...this.logContext,
1173
- track: pub.trackSid,
1174
- });
1175
- await this.localParticipant.publishTrack(track, pub.options);
1176
- }
1177
- }),
1178
- );
1170
+ await this.localParticipant.republishAllTracks(undefined, true);
1179
1171
  } catch (error) {
1180
1172
  this.log.error('error trying to re-publish tracks after reconnection', {
1181
1173
  ...this.logContext,
@@ -1681,6 +1673,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1681
1673
  this.log.warn('detected connection state mismatch', {
1682
1674
  ...this.logContext,
1683
1675
  numFailures: consecutiveFailures,
1676
+ engine: {
1677
+ closed: this.engine.isClosed,
1678
+ transportsConnected: this.engine.verifyTransport(),
1679
+ },
1684
1680
  });
1685
1681
  if (consecutiveFailures >= 3) {
1686
1682
  this.recreateEngine();
@@ -1832,7 +1828,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1832
1828
  await window.navigator.mediaDevices.getUserMedia({ video: true })
1833
1829
  ).getVideoTracks()[0]
1834
1830
  : createDummyVideoStreamTrack(
1835
- 160 * participantOptions.aspectRatios[0] ?? 1,
1831
+ 160 * (participantOptions.aspectRatios[0] ?? 1),
1836
1832
  160,
1837
1833
  true,
1838
1834
  true,
@@ -1882,7 +1878,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
1882
1878
  const p = this.getOrCreateParticipant(info.identity, info);
1883
1879
  if (participantOptions.video) {
1884
1880
  const dummyVideo = createDummyVideoStreamTrack(
1885
- 160 * participantOptions.aspectRatios[i % participantOptions.aspectRatios.length] ?? 1,
1881
+ 160 * (participantOptions.aspectRatios[i % participantOptions.aspectRatios.length] ?? 1),
1886
1882
  160,
1887
1883
  false,
1888
1884
  true,
@@ -1109,6 +1109,8 @@ export default class LocalParticipant extends Participant {
1109
1109
  if (
1110
1110
  restartTracks &&
1111
1111
  !track.isMuted &&
1112
+ track.source !== Track.Source.ScreenShare &&
1113
+ track.source !== Track.Source.ScreenShareAudio &&
1112
1114
  (track instanceof LocalAudioTrack || track instanceof LocalVideoTrack) &&
1113
1115
  !track.isUserProvided
1114
1116
  ) {
package/src/room/types.ts CHANGED
@@ -40,7 +40,9 @@ export type SimulationScenario =
40
40
  // overrides server-side bandwidth estimator with set bandwidth
41
41
  // this can be used to test application behavior when congested or
42
42
  // to disable congestion control entirely (by setting bandwidth to 100Mbps)
43
- | 'subscriber-bandwidth';
43
+ | 'subscriber-bandwidth'
44
+ | 'disconnect-signal-on-resume'
45
+ | 'disconnect-signal-on-resume-no-messages';
44
46
 
45
47
  export type LoggerOptions = {
46
48
  loggerName?: string;