livekit-client 1.6.6 → 1.6.8

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.
Files changed (57) hide show
  1. package/dist/livekit-client.esm.mjs +508 -317
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/proto/google/protobuf/timestamp.d.ts +9 -2
  6. package/dist/src/proto/google/protobuf/timestamp.d.ts.map +1 -1
  7. package/dist/src/proto/livekit_models.d.ts +958 -58
  8. package/dist/src/proto/livekit_models.d.ts.map +1 -1
  9. package/dist/src/proto/livekit_rtc.d.ts +8394 -3725
  10. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  11. package/dist/src/room/PCTransport.d.ts.map +1 -1
  12. package/dist/src/room/RTCEngine.d.ts +10 -3
  13. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  14. package/dist/src/room/Room.d.ts +1 -1
  15. package/dist/src/room/Room.d.ts.map +1 -1
  16. package/dist/src/room/events.d.ts +1 -1
  17. package/dist/src/room/participant/LocalParticipant.d.ts +18 -0
  18. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  19. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  20. package/dist/src/room/track/RemoteTrackPublication.d.ts +1 -1
  21. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  22. package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
  23. package/dist/src/room/track/Track.d.ts +2 -1
  24. package/dist/src/room/track/Track.d.ts.map +1 -1
  25. package/dist/src/room/track/options.d.ts +10 -2
  26. package/dist/src/room/track/options.d.ts.map +1 -1
  27. package/dist/src/room/types.d.ts +7 -0
  28. package/dist/src/room/types.d.ts.map +1 -1
  29. package/dist/src/version.d.ts +1 -1
  30. package/dist/ts4.2/src/proto/google/protobuf/timestamp.d.ts +11 -2
  31. package/dist/ts4.2/src/proto/livekit_models.d.ts +1199 -177
  32. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +9260 -4023
  33. package/dist/ts4.2/src/room/RTCEngine.d.ts +10 -3
  34. package/dist/ts4.2/src/room/Room.d.ts +1 -1
  35. package/dist/ts4.2/src/room/events.d.ts +1 -1
  36. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +18 -0
  37. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +1 -1
  38. package/dist/ts4.2/src/room/track/Track.d.ts +2 -1
  39. package/dist/ts4.2/src/room/track/options.d.ts +10 -2
  40. package/dist/ts4.2/src/room/types.d.ts +7 -0
  41. package/dist/ts4.2/src/version.d.ts +1 -1
  42. package/package.json +14 -14
  43. package/src/proto/google/protobuf/timestamp.ts +4 -0
  44. package/src/proto/livekit_models.ts +128 -31
  45. package/src/proto/livekit_rtc.ts +262 -161
  46. package/src/room/PCTransport.ts +2 -0
  47. package/src/room/RTCEngine.ts +50 -55
  48. package/src/room/Room.ts +60 -43
  49. package/src/room/events.ts +1 -1
  50. package/src/room/participant/LocalParticipant.ts +118 -28
  51. package/src/room/participant/RemoteParticipant.ts +2 -3
  52. package/src/room/track/RemoteTrackPublication.ts +3 -2
  53. package/src/room/track/RemoteVideoTrack.ts +0 -3
  54. package/src/room/track/Track.ts +2 -1
  55. package/src/room/track/options.ts +14 -2
  56. package/src/room/types.ts +9 -0
  57. package/src/version.ts +1 -1
@@ -4290,11 +4290,11 @@ function disconnectReasonToJSON(object) {
4290
4290
  }
4291
4291
  var ReconnectReason;
4292
4292
  (function (ReconnectReason) {
4293
- ReconnectReason[ReconnectReason["REASON_UNKOWN"] = 0] = "REASON_UNKOWN";
4294
- ReconnectReason[ReconnectReason["REASON_SIGNAL_DISCONNECTED"] = 1] = "REASON_SIGNAL_DISCONNECTED";
4295
- ReconnectReason[ReconnectReason["REASON_PUBLISHER_FAILED"] = 2] = "REASON_PUBLISHER_FAILED";
4296
- ReconnectReason[ReconnectReason["REASON_SUBSCRIBER_FAILED"] = 3] = "REASON_SUBSCRIBER_FAILED";
4297
- ReconnectReason[ReconnectReason["REASON_SWITCH_CANDIDATE"] = 4] = "REASON_SWITCH_CANDIDATE";
4293
+ ReconnectReason[ReconnectReason["RR_UNKOWN"] = 0] = "RR_UNKOWN";
4294
+ ReconnectReason[ReconnectReason["RR_SIGNAL_DISCONNECTED"] = 1] = "RR_SIGNAL_DISCONNECTED";
4295
+ ReconnectReason[ReconnectReason["RR_PUBLISHER_FAILED"] = 2] = "RR_PUBLISHER_FAILED";
4296
+ ReconnectReason[ReconnectReason["RR_SUBSCRIBER_FAILED"] = 3] = "RR_SUBSCRIBER_FAILED";
4297
+ ReconnectReason[ReconnectReason["RR_SWITCH_CANDIDATE"] = 4] = "RR_SWITCH_CANDIDATE";
4298
4298
  ReconnectReason[ReconnectReason["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
4299
4299
  })(ReconnectReason || (ReconnectReason = {}));
4300
4300
  var ParticipantInfo_State;
@@ -4629,6 +4629,9 @@ const Room$1 = {
4629
4629
  message.activeRecording !== undefined && (obj.activeRecording = message.activeRecording);
4630
4630
  return obj;
4631
4631
  },
4632
+ create(base) {
4633
+ return Room$1.fromPartial(base !== null && base !== void 0 ? base : {});
4634
+ },
4632
4635
  fromPartial(object) {
4633
4636
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4634
4637
  const message = createBaseRoom();
@@ -4694,6 +4697,9 @@ const Codec = {
4694
4697
  message.fmtpLine !== undefined && (obj.fmtpLine = message.fmtpLine);
4695
4698
  return obj;
4696
4699
  },
4700
+ create(base) {
4701
+ return Codec.fromPartial(base !== null && base !== void 0 ? base : {});
4702
+ },
4697
4703
  fromPartial(object) {
4698
4704
  var _a, _b;
4699
4705
  const message = createBaseCodec();
@@ -4800,6 +4806,9 @@ const ParticipantPermission = {
4800
4806
  message.recorder !== undefined && (obj.recorder = message.recorder);
4801
4807
  return obj;
4802
4808
  },
4809
+ create(base) {
4810
+ return ParticipantPermission.fromPartial(base !== null && base !== void 0 ? base : {});
4811
+ },
4803
4812
  fromPartial(object) {
4804
4813
  var _a, _b, _c, _d, _e, _f;
4805
4814
  const message = createBaseParticipantPermission();
@@ -4946,6 +4955,9 @@ const ParticipantInfo = {
4946
4955
  message.isPublisher !== undefined && (obj.isPublisher = message.isPublisher);
4947
4956
  return obj;
4948
4957
  },
4958
+ create(base) {
4959
+ return ParticipantInfo.fromPartial(base !== null && base !== void 0 ? base : {});
4960
+ },
4949
4961
  fromPartial(object) {
4950
4962
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4951
4963
  const message = createBaseParticipantInfo();
@@ -5034,6 +5046,9 @@ const SimulcastCodecInfo = {
5034
5046
  }
5035
5047
  return obj;
5036
5048
  },
5049
+ create(base) {
5050
+ return SimulcastCodecInfo.fromPartial(base !== null && base !== void 0 ? base : {});
5051
+ },
5037
5052
  fromPartial(object) {
5038
5053
  var _a, _b, _c, _d;
5039
5054
  const message = createBaseSimulcastCodecInfo();
@@ -5227,6 +5242,9 @@ const TrackInfo = {
5227
5242
  message.encryption !== undefined && (obj.encryption = encryption_TypeToJSON(message.encryption));
5228
5243
  return obj;
5229
5244
  },
5245
+ create(base) {
5246
+ return TrackInfo.fromPartial(base !== null && base !== void 0 ? base : {});
5247
+ },
5230
5248
  fromPartial(object) {
5231
5249
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
5232
5250
  const message = createBaseTrackInfo();
@@ -5325,6 +5343,9 @@ const VideoLayer = {
5325
5343
  message.ssrc !== undefined && (obj.ssrc = Math.round(message.ssrc));
5326
5344
  return obj;
5327
5345
  },
5346
+ create(base) {
5347
+ return VideoLayer.fromPartial(base !== null && base !== void 0 ? base : {});
5348
+ },
5328
5349
  fromPartial(object) {
5329
5350
  var _a, _b, _c, _d, _e;
5330
5351
  const message = createBaseVideoLayer();
@@ -5345,15 +5366,17 @@ function createBaseDataPacket() {
5345
5366
  const DataPacket = {
5346
5367
  encode(message) {
5347
5368
  let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
5348
- var _a, _b;
5369
+ var _a;
5349
5370
  if (message.kind !== 0) {
5350
5371
  writer.uint32(8).int32(message.kind);
5351
5372
  }
5352
- if (((_a = message.value) === null || _a === void 0 ? void 0 : _a.$case) === "user") {
5353
- UserPacket.encode(message.value.user, writer.uint32(18).fork()).ldelim();
5354
- }
5355
- if (((_b = message.value) === null || _b === void 0 ? void 0 : _b.$case) === "speaker") {
5356
- ActiveSpeakerUpdate.encode(message.value.speaker, writer.uint32(26).fork()).ldelim();
5373
+ switch ((_a = message.value) === null || _a === void 0 ? void 0 : _a.$case) {
5374
+ case "user":
5375
+ UserPacket.encode(message.value.user, writer.uint32(18).fork()).ldelim();
5376
+ break;
5377
+ case "speaker":
5378
+ ActiveSpeakerUpdate.encode(message.value.speaker, writer.uint32(26).fork()).ldelim();
5379
+ break;
5357
5380
  }
5358
5381
  return writer;
5359
5382
  },
@@ -5406,6 +5429,9 @@ const DataPacket = {
5406
5429
  ((_d = message.value) === null || _d === void 0 ? void 0 : _d.$case) === "speaker" && (obj.speaker = ((_e = message.value) === null || _e === void 0 ? void 0 : _e.speaker) ? ActiveSpeakerUpdate.toJSON((_f = message.value) === null || _f === void 0 ? void 0 : _f.speaker) : undefined);
5407
5430
  return obj;
5408
5431
  },
5432
+ create(base) {
5433
+ return DataPacket.fromPartial(base !== null && base !== void 0 ? base : {});
5434
+ },
5409
5435
  fromPartial(object) {
5410
5436
  var _a, _b, _c, _d, _e, _f, _g;
5411
5437
  const message = createBaseDataPacket();
@@ -5469,6 +5495,9 @@ const ActiveSpeakerUpdate = {
5469
5495
  }
5470
5496
  return obj;
5471
5497
  },
5498
+ create(base) {
5499
+ return ActiveSpeakerUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
5500
+ },
5472
5501
  fromPartial(object) {
5473
5502
  var _a;
5474
5503
  const message = createBaseActiveSpeakerUpdate();
@@ -5534,6 +5563,9 @@ const SpeakerInfo = {
5534
5563
  message.active !== undefined && (obj.active = message.active);
5535
5564
  return obj;
5536
5565
  },
5566
+ create(base) {
5567
+ return SpeakerInfo.fromPartial(base !== null && base !== void 0 ? base : {});
5568
+ },
5537
5569
  fromPartial(object) {
5538
5570
  var _a, _b, _c;
5539
5571
  const message = createBaseSpeakerInfo();
@@ -5547,7 +5579,8 @@ function createBaseUserPacket() {
5547
5579
  return {
5548
5580
  participantSid: "",
5549
5581
  payload: new Uint8Array(),
5550
- destinationSids: []
5582
+ destinationSids: [],
5583
+ topic: undefined
5551
5584
  };
5552
5585
  }
5553
5586
  const UserPacket = {
@@ -5562,6 +5595,9 @@ const UserPacket = {
5562
5595
  for (const v of message.destinationSids) {
5563
5596
  writer.uint32(26).string(v);
5564
5597
  }
5598
+ if (message.topic !== undefined) {
5599
+ writer.uint32(34).string(message.topic);
5600
+ }
5565
5601
  return writer;
5566
5602
  },
5567
5603
  decode(input, length) {
@@ -5580,6 +5616,9 @@ const UserPacket = {
5580
5616
  case 3:
5581
5617
  message.destinationSids.push(reader.string());
5582
5618
  break;
5619
+ case 4:
5620
+ message.topic = reader.string();
5621
+ break;
5583
5622
  default:
5584
5623
  reader.skipType(tag & 7);
5585
5624
  break;
@@ -5591,7 +5630,8 @@ const UserPacket = {
5591
5630
  return {
5592
5631
  participantSid: isSet$1(object.participantSid) ? String(object.participantSid) : "",
5593
5632
  payload: isSet$1(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(),
5594
- destinationSids: Array.isArray(object === null || object === void 0 ? void 0 : object.destinationSids) ? object.destinationSids.map(e => String(e)) : []
5633
+ destinationSids: Array.isArray(object === null || object === void 0 ? void 0 : object.destinationSids) ? object.destinationSids.map(e => String(e)) : [],
5634
+ topic: isSet$1(object.topic) ? String(object.topic) : undefined
5595
5635
  };
5596
5636
  },
5597
5637
  toJSON(message) {
@@ -5603,14 +5643,19 @@ const UserPacket = {
5603
5643
  } else {
5604
5644
  obj.destinationSids = [];
5605
5645
  }
5646
+ message.topic !== undefined && (obj.topic = message.topic);
5606
5647
  return obj;
5607
5648
  },
5649
+ create(base) {
5650
+ return UserPacket.fromPartial(base !== null && base !== void 0 ? base : {});
5651
+ },
5608
5652
  fromPartial(object) {
5609
- var _a, _b, _c;
5653
+ var _a, _b, _c, _d;
5610
5654
  const message = createBaseUserPacket();
5611
5655
  message.participantSid = (_a = object.participantSid) !== null && _a !== void 0 ? _a : "";
5612
5656
  message.payload = (_b = object.payload) !== null && _b !== void 0 ? _b : new Uint8Array();
5613
5657
  message.destinationSids = ((_c = object.destinationSids) === null || _c === void 0 ? void 0 : _c.map(e => e)) || [];
5658
+ message.topic = (_d = object.topic) !== null && _d !== void 0 ? _d : undefined;
5614
5659
  return message;
5615
5660
  }
5616
5661
  };
@@ -5667,6 +5712,9 @@ const ParticipantTracks = {
5667
5712
  }
5668
5713
  return obj;
5669
5714
  },
5715
+ create(base) {
5716
+ return ParticipantTracks.fromPartial(base !== null && base !== void 0 ? base : {});
5717
+ },
5670
5718
  fromPartial(object) {
5671
5719
  var _a, _b;
5672
5720
  const message = createBaseParticipantTracks();
@@ -5760,6 +5808,9 @@ const ServerInfo = {
5760
5808
  message.debugInfo !== undefined && (obj.debugInfo = message.debugInfo);
5761
5809
  return obj;
5762
5810
  },
5811
+ create(base) {
5812
+ return ServerInfo.fromPartial(base !== null && base !== void 0 ? base : {});
5813
+ },
5763
5814
  fromPartial(object) {
5764
5815
  var _a, _b, _c, _d, _e, _f;
5765
5816
  const message = createBaseServerInfo();
@@ -5893,6 +5944,9 @@ const ClientInfo = {
5893
5944
  message.network !== undefined && (obj.network = message.network);
5894
5945
  return obj;
5895
5946
  },
5947
+ create(base) {
5948
+ return ClientInfo.fromPartial(base !== null && base !== void 0 ? base : {});
5949
+ },
5896
5950
  fromPartial(object) {
5897
5951
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5898
5952
  const message = createBaseClientInfo();
@@ -5985,6 +6039,9 @@ const ClientConfiguration = {
5985
6039
  message.forceRelay !== undefined && (obj.forceRelay = clientConfigSettingToJSON(message.forceRelay));
5986
6040
  return obj;
5987
6041
  },
6042
+ create(base) {
6043
+ return ClientConfiguration.fromPartial(base !== null && base !== void 0 ? base : {});
6044
+ },
5988
6045
  fromPartial(object) {
5989
6046
  var _a, _b;
5990
6047
  const message = createBaseClientConfiguration();
@@ -6036,6 +6093,9 @@ const VideoConfiguration = {
6036
6093
  message.hardwareEncoder !== undefined && (obj.hardwareEncoder = clientConfigSettingToJSON(message.hardwareEncoder));
6037
6094
  return obj;
6038
6095
  },
6096
+ create(base) {
6097
+ return VideoConfiguration.fromPartial(base !== null && base !== void 0 ? base : {});
6098
+ },
6039
6099
  fromPartial(object) {
6040
6100
  var _a;
6041
6101
  const message = createBaseVideoConfiguration();
@@ -6087,6 +6147,9 @@ const DisabledCodecs = {
6087
6147
  }
6088
6148
  return obj;
6089
6149
  },
6150
+ create(base) {
6151
+ return DisabledCodecs.fromPartial(base !== null && base !== void 0 ? base : {});
6152
+ },
6090
6153
  fromPartial(object) {
6091
6154
  var _a;
6092
6155
  const message = createBaseDisabledCodecs();
@@ -9426,51 +9489,53 @@ function createBaseSignalRequest() {
9426
9489
  const SignalRequest = {
9427
9490
  encode(message) {
9428
9491
  let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
9429
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
9430
- if (((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) === "offer") {
9431
- SessionDescription.encode(message.message.offer, writer.uint32(10).fork()).ldelim();
9432
- }
9433
- if (((_b = message.message) === null || _b === void 0 ? void 0 : _b.$case) === "answer") {
9434
- SessionDescription.encode(message.message.answer, writer.uint32(18).fork()).ldelim();
9435
- }
9436
- if (((_c = message.message) === null || _c === void 0 ? void 0 : _c.$case) === "trickle") {
9437
- TrickleRequest.encode(message.message.trickle, writer.uint32(26).fork()).ldelim();
9438
- }
9439
- if (((_d = message.message) === null || _d === void 0 ? void 0 : _d.$case) === "addTrack") {
9440
- AddTrackRequest.encode(message.message.addTrack, writer.uint32(34).fork()).ldelim();
9441
- }
9442
- if (((_e = message.message) === null || _e === void 0 ? void 0 : _e.$case) === "mute") {
9443
- MuteTrackRequest.encode(message.message.mute, writer.uint32(42).fork()).ldelim();
9444
- }
9445
- if (((_f = message.message) === null || _f === void 0 ? void 0 : _f.$case) === "subscription") {
9446
- UpdateSubscription.encode(message.message.subscription, writer.uint32(50).fork()).ldelim();
9447
- }
9448
- if (((_g = message.message) === null || _g === void 0 ? void 0 : _g.$case) === "trackSetting") {
9449
- UpdateTrackSettings.encode(message.message.trackSetting, writer.uint32(58).fork()).ldelim();
9450
- }
9451
- if (((_h = message.message) === null || _h === void 0 ? void 0 : _h.$case) === "leave") {
9452
- LeaveRequest.encode(message.message.leave, writer.uint32(66).fork()).ldelim();
9453
- }
9454
- if (((_j = message.message) === null || _j === void 0 ? void 0 : _j.$case) === "updateLayers") {
9455
- UpdateVideoLayers.encode(message.message.updateLayers, writer.uint32(82).fork()).ldelim();
9456
- }
9457
- if (((_k = message.message) === null || _k === void 0 ? void 0 : _k.$case) === "subscriptionPermission") {
9458
- SubscriptionPermission.encode(message.message.subscriptionPermission, writer.uint32(90).fork()).ldelim();
9459
- }
9460
- if (((_l = message.message) === null || _l === void 0 ? void 0 : _l.$case) === "syncState") {
9461
- SyncState.encode(message.message.syncState, writer.uint32(98).fork()).ldelim();
9462
- }
9463
- if (((_m = message.message) === null || _m === void 0 ? void 0 : _m.$case) === "simulate") {
9464
- SimulateScenario.encode(message.message.simulate, writer.uint32(106).fork()).ldelim();
9465
- }
9466
- if (((_o = message.message) === null || _o === void 0 ? void 0 : _o.$case) === "ping") {
9467
- writer.uint32(112).int64(message.message.ping);
9468
- }
9469
- if (((_p = message.message) === null || _p === void 0 ? void 0 : _p.$case) === "updateMetadata") {
9470
- UpdateParticipantMetadata.encode(message.message.updateMetadata, writer.uint32(122).fork()).ldelim();
9471
- }
9472
- if (((_q = message.message) === null || _q === void 0 ? void 0 : _q.$case) === "pingReq") {
9473
- Ping.encode(message.message.pingReq, writer.uint32(130).fork()).ldelim();
9492
+ var _a;
9493
+ switch ((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) {
9494
+ case "offer":
9495
+ SessionDescription.encode(message.message.offer, writer.uint32(10).fork()).ldelim();
9496
+ break;
9497
+ case "answer":
9498
+ SessionDescription.encode(message.message.answer, writer.uint32(18).fork()).ldelim();
9499
+ break;
9500
+ case "trickle":
9501
+ TrickleRequest.encode(message.message.trickle, writer.uint32(26).fork()).ldelim();
9502
+ break;
9503
+ case "addTrack":
9504
+ AddTrackRequest.encode(message.message.addTrack, writer.uint32(34).fork()).ldelim();
9505
+ break;
9506
+ case "mute":
9507
+ MuteTrackRequest.encode(message.message.mute, writer.uint32(42).fork()).ldelim();
9508
+ break;
9509
+ case "subscription":
9510
+ UpdateSubscription.encode(message.message.subscription, writer.uint32(50).fork()).ldelim();
9511
+ break;
9512
+ case "trackSetting":
9513
+ UpdateTrackSettings.encode(message.message.trackSetting, writer.uint32(58).fork()).ldelim();
9514
+ break;
9515
+ case "leave":
9516
+ LeaveRequest.encode(message.message.leave, writer.uint32(66).fork()).ldelim();
9517
+ break;
9518
+ case "updateLayers":
9519
+ UpdateVideoLayers.encode(message.message.updateLayers, writer.uint32(82).fork()).ldelim();
9520
+ break;
9521
+ case "subscriptionPermission":
9522
+ SubscriptionPermission.encode(message.message.subscriptionPermission, writer.uint32(90).fork()).ldelim();
9523
+ break;
9524
+ case "syncState":
9525
+ SyncState.encode(message.message.syncState, writer.uint32(98).fork()).ldelim();
9526
+ break;
9527
+ case "simulate":
9528
+ SimulateScenario.encode(message.message.simulate, writer.uint32(106).fork()).ldelim();
9529
+ break;
9530
+ case "ping":
9531
+ writer.uint32(112).int64(message.message.ping);
9532
+ break;
9533
+ case "updateMetadata":
9534
+ UpdateParticipantMetadata.encode(message.message.updateMetadata, writer.uint32(122).fork()).ldelim();
9535
+ break;
9536
+ case "pingReq":
9537
+ Ping.encode(message.message.pingReq, writer.uint32(130).fork()).ldelim();
9538
+ break;
9474
9539
  }
9475
9540
  return writer;
9476
9541
  },
@@ -9648,6 +9713,9 @@ const SignalRequest = {
9648
9713
  ((_17 = message.message) === null || _17 === void 0 ? void 0 : _17.$case) === "pingReq" && (obj.pingReq = ((_18 = message.message) === null || _18 === void 0 ? void 0 : _18.pingReq) ? Ping.toJSON((_19 = message.message) === null || _19 === void 0 ? void 0 : _19.pingReq) : undefined);
9649
9714
  return obj;
9650
9715
  },
9716
+ create(base) {
9717
+ return SignalRequest.fromPartial(base !== null && base !== void 0 ? base : {});
9718
+ },
9651
9719
  fromPartial(object) {
9652
9720
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20;
9653
9721
  const message = createBaseSignalRequest();
@@ -9752,63 +9820,65 @@ function createBaseSignalResponse() {
9752
9820
  const SignalResponse = {
9753
9821
  encode(message) {
9754
9822
  let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
9755
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
9756
- if (((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) === "join") {
9757
- JoinResponse.encode(message.message.join, writer.uint32(10).fork()).ldelim();
9758
- }
9759
- if (((_b = message.message) === null || _b === void 0 ? void 0 : _b.$case) === "answer") {
9760
- SessionDescription.encode(message.message.answer, writer.uint32(18).fork()).ldelim();
9761
- }
9762
- if (((_c = message.message) === null || _c === void 0 ? void 0 : _c.$case) === "offer") {
9763
- SessionDescription.encode(message.message.offer, writer.uint32(26).fork()).ldelim();
9764
- }
9765
- if (((_d = message.message) === null || _d === void 0 ? void 0 : _d.$case) === "trickle") {
9766
- TrickleRequest.encode(message.message.trickle, writer.uint32(34).fork()).ldelim();
9767
- }
9768
- if (((_e = message.message) === null || _e === void 0 ? void 0 : _e.$case) === "update") {
9769
- ParticipantUpdate.encode(message.message.update, writer.uint32(42).fork()).ldelim();
9770
- }
9771
- if (((_f = message.message) === null || _f === void 0 ? void 0 : _f.$case) === "trackPublished") {
9772
- TrackPublishedResponse.encode(message.message.trackPublished, writer.uint32(50).fork()).ldelim();
9773
- }
9774
- if (((_g = message.message) === null || _g === void 0 ? void 0 : _g.$case) === "leave") {
9775
- LeaveRequest.encode(message.message.leave, writer.uint32(66).fork()).ldelim();
9776
- }
9777
- if (((_h = message.message) === null || _h === void 0 ? void 0 : _h.$case) === "mute") {
9778
- MuteTrackRequest.encode(message.message.mute, writer.uint32(74).fork()).ldelim();
9779
- }
9780
- if (((_j = message.message) === null || _j === void 0 ? void 0 : _j.$case) === "speakersChanged") {
9781
- SpeakersChanged.encode(message.message.speakersChanged, writer.uint32(82).fork()).ldelim();
9782
- }
9783
- if (((_k = message.message) === null || _k === void 0 ? void 0 : _k.$case) === "roomUpdate") {
9784
- RoomUpdate.encode(message.message.roomUpdate, writer.uint32(90).fork()).ldelim();
9785
- }
9786
- if (((_l = message.message) === null || _l === void 0 ? void 0 : _l.$case) === "connectionQuality") {
9787
- ConnectionQualityUpdate.encode(message.message.connectionQuality, writer.uint32(98).fork()).ldelim();
9788
- }
9789
- if (((_m = message.message) === null || _m === void 0 ? void 0 : _m.$case) === "streamStateUpdate") {
9790
- StreamStateUpdate.encode(message.message.streamStateUpdate, writer.uint32(106).fork()).ldelim();
9791
- }
9792
- if (((_o = message.message) === null || _o === void 0 ? void 0 : _o.$case) === "subscribedQualityUpdate") {
9793
- SubscribedQualityUpdate.encode(message.message.subscribedQualityUpdate, writer.uint32(114).fork()).ldelim();
9794
- }
9795
- if (((_p = message.message) === null || _p === void 0 ? void 0 : _p.$case) === "subscriptionPermissionUpdate") {
9796
- SubscriptionPermissionUpdate.encode(message.message.subscriptionPermissionUpdate, writer.uint32(122).fork()).ldelim();
9797
- }
9798
- if (((_q = message.message) === null || _q === void 0 ? void 0 : _q.$case) === "refreshToken") {
9799
- writer.uint32(130).string(message.message.refreshToken);
9800
- }
9801
- if (((_r = message.message) === null || _r === void 0 ? void 0 : _r.$case) === "trackUnpublished") {
9802
- TrackUnpublishedResponse.encode(message.message.trackUnpublished, writer.uint32(138).fork()).ldelim();
9803
- }
9804
- if (((_s = message.message) === null || _s === void 0 ? void 0 : _s.$case) === "pong") {
9805
- writer.uint32(144).int64(message.message.pong);
9806
- }
9807
- if (((_t = message.message) === null || _t === void 0 ? void 0 : _t.$case) === "reconnect") {
9808
- ReconnectResponse.encode(message.message.reconnect, writer.uint32(154).fork()).ldelim();
9809
- }
9810
- if (((_u = message.message) === null || _u === void 0 ? void 0 : _u.$case) === "pongResp") {
9811
- Pong.encode(message.message.pongResp, writer.uint32(162).fork()).ldelim();
9823
+ var _a;
9824
+ switch ((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) {
9825
+ case "join":
9826
+ JoinResponse.encode(message.message.join, writer.uint32(10).fork()).ldelim();
9827
+ break;
9828
+ case "answer":
9829
+ SessionDescription.encode(message.message.answer, writer.uint32(18).fork()).ldelim();
9830
+ break;
9831
+ case "offer":
9832
+ SessionDescription.encode(message.message.offer, writer.uint32(26).fork()).ldelim();
9833
+ break;
9834
+ case "trickle":
9835
+ TrickleRequest.encode(message.message.trickle, writer.uint32(34).fork()).ldelim();
9836
+ break;
9837
+ case "update":
9838
+ ParticipantUpdate.encode(message.message.update, writer.uint32(42).fork()).ldelim();
9839
+ break;
9840
+ case "trackPublished":
9841
+ TrackPublishedResponse.encode(message.message.trackPublished, writer.uint32(50).fork()).ldelim();
9842
+ break;
9843
+ case "leave":
9844
+ LeaveRequest.encode(message.message.leave, writer.uint32(66).fork()).ldelim();
9845
+ break;
9846
+ case "mute":
9847
+ MuteTrackRequest.encode(message.message.mute, writer.uint32(74).fork()).ldelim();
9848
+ break;
9849
+ case "speakersChanged":
9850
+ SpeakersChanged.encode(message.message.speakersChanged, writer.uint32(82).fork()).ldelim();
9851
+ break;
9852
+ case "roomUpdate":
9853
+ RoomUpdate.encode(message.message.roomUpdate, writer.uint32(90).fork()).ldelim();
9854
+ break;
9855
+ case "connectionQuality":
9856
+ ConnectionQualityUpdate.encode(message.message.connectionQuality, writer.uint32(98).fork()).ldelim();
9857
+ break;
9858
+ case "streamStateUpdate":
9859
+ StreamStateUpdate.encode(message.message.streamStateUpdate, writer.uint32(106).fork()).ldelim();
9860
+ break;
9861
+ case "subscribedQualityUpdate":
9862
+ SubscribedQualityUpdate.encode(message.message.subscribedQualityUpdate, writer.uint32(114).fork()).ldelim();
9863
+ break;
9864
+ case "subscriptionPermissionUpdate":
9865
+ SubscriptionPermissionUpdate.encode(message.message.subscriptionPermissionUpdate, writer.uint32(122).fork()).ldelim();
9866
+ break;
9867
+ case "refreshToken":
9868
+ writer.uint32(130).string(message.message.refreshToken);
9869
+ break;
9870
+ case "trackUnpublished":
9871
+ TrackUnpublishedResponse.encode(message.message.trackUnpublished, writer.uint32(138).fork()).ldelim();
9872
+ break;
9873
+ case "pong":
9874
+ writer.uint32(144).int64(message.message.pong);
9875
+ break;
9876
+ case "reconnect":
9877
+ ReconnectResponse.encode(message.message.reconnect, writer.uint32(154).fork()).ldelim();
9878
+ break;
9879
+ case "pongResp":
9880
+ Pong.encode(message.message.pongResp, writer.uint32(162).fork()).ldelim();
9881
+ break;
9812
9882
  }
9813
9883
  return writer;
9814
9884
  },
@@ -10026,6 +10096,9 @@ const SignalResponse = {
10026
10096
  ((_28 = message.message) === null || _28 === void 0 ? void 0 : _28.$case) === "pongResp" && (obj.pongResp = ((_29 = message.message) === null || _29 === void 0 ? void 0 : _29.pongResp) ? Pong.toJSON((_30 = message.message) === null || _30 === void 0 ? void 0 : _30.pongResp) : undefined);
10027
10097
  return obj;
10028
10098
  },
10099
+ create(base) {
10100
+ return SignalResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10101
+ },
10029
10102
  fromPartial(object) {
10030
10103
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32;
10031
10104
  const message = createBaseSignalResponse();
@@ -10204,6 +10277,9 @@ const SimulcastCodec = {
10204
10277
  message.enableSimulcastLayers !== undefined && (obj.enableSimulcastLayers = message.enableSimulcastLayers);
10205
10278
  return obj;
10206
10279
  },
10280
+ create(base) {
10281
+ return SimulcastCodec.fromPartial(base !== null && base !== void 0 ? base : {});
10282
+ },
10207
10283
  fromPartial(object) {
10208
10284
  var _a, _b, _c;
10209
10285
  const message = createBaseSimulcastCodec();
@@ -10378,6 +10454,9 @@ const AddTrackRequest = {
10378
10454
  message.encryption !== undefined && (obj.encryption = encryption_TypeToJSON(message.encryption));
10379
10455
  return obj;
10380
10456
  },
10457
+ create(base) {
10458
+ return AddTrackRequest.fromPartial(base !== null && base !== void 0 ? base : {});
10459
+ },
10381
10460
  fromPartial(object) {
10382
10461
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
10383
10462
  const message = createBaseAddTrackRequest();
@@ -10447,6 +10526,9 @@ const TrickleRequest = {
10447
10526
  message.target !== undefined && (obj.target = signalTargetToJSON(message.target));
10448
10527
  return obj;
10449
10528
  },
10529
+ create(base) {
10530
+ return TrickleRequest.fromPartial(base !== null && base !== void 0 ? base : {});
10531
+ },
10450
10532
  fromPartial(object) {
10451
10533
  var _a, _b;
10452
10534
  const message = createBaseTrickleRequest();
@@ -10504,6 +10586,9 @@ const MuteTrackRequest = {
10504
10586
  message.muted !== undefined && (obj.muted = message.muted);
10505
10587
  return obj;
10506
10588
  },
10589
+ create(base) {
10590
+ return MuteTrackRequest.fromPartial(base !== null && base !== void 0 ? base : {});
10591
+ },
10507
10592
  fromPartial(object) {
10508
10593
  var _a, _b;
10509
10594
  const message = createBaseMuteTrackRequest();
@@ -10659,6 +10744,9 @@ const JoinResponse = {
10659
10744
  message.serverInfo !== undefined && (obj.serverInfo = message.serverInfo ? ServerInfo.toJSON(message.serverInfo) : undefined);
10660
10745
  return obj;
10661
10746
  },
10747
+ create(base) {
10748
+ return JoinResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10749
+ },
10662
10750
  fromPartial(object) {
10663
10751
  var _a, _b, _c, _d, _e, _f, _g, _h;
10664
10752
  const message = createBaseJoinResponse();
@@ -10680,10 +10768,7 @@ const JoinResponse = {
10680
10768
  function createBaseReconnectResponse() {
10681
10769
  return {
10682
10770
  iceServers: [],
10683
- clientConfiguration: undefined,
10684
- room: undefined,
10685
- participant: undefined,
10686
- otherParticipants: []
10771
+ clientConfiguration: undefined
10687
10772
  };
10688
10773
  }
10689
10774
  const ReconnectResponse = {
@@ -10695,15 +10780,6 @@ const ReconnectResponse = {
10695
10780
  if (message.clientConfiguration !== undefined) {
10696
10781
  ClientConfiguration.encode(message.clientConfiguration, writer.uint32(18).fork()).ldelim();
10697
10782
  }
10698
- if (message.room !== undefined) {
10699
- Room$1.encode(message.room, writer.uint32(26).fork()).ldelim();
10700
- }
10701
- if (message.participant !== undefined) {
10702
- ParticipantInfo.encode(message.participant, writer.uint32(34).fork()).ldelim();
10703
- }
10704
- for (const v of message.otherParticipants) {
10705
- ParticipantInfo.encode(v, writer.uint32(42).fork()).ldelim();
10706
- }
10707
10783
  return writer;
10708
10784
  },
10709
10785
  decode(input, length) {
@@ -10719,15 +10795,6 @@ const ReconnectResponse = {
10719
10795
  case 2:
10720
10796
  message.clientConfiguration = ClientConfiguration.decode(reader, reader.uint32());
10721
10797
  break;
10722
- case 3:
10723
- message.room = Room$1.decode(reader, reader.uint32());
10724
- break;
10725
- case 4:
10726
- message.participant = ParticipantInfo.decode(reader, reader.uint32());
10727
- break;
10728
- case 5:
10729
- message.otherParticipants.push(ParticipantInfo.decode(reader, reader.uint32()));
10730
- break;
10731
10798
  default:
10732
10799
  reader.skipType(tag & 7);
10733
10800
  break;
@@ -10738,10 +10805,7 @@ const ReconnectResponse = {
10738
10805
  fromJSON(object) {
10739
10806
  return {
10740
10807
  iceServers: Array.isArray(object === null || object === void 0 ? void 0 : object.iceServers) ? object.iceServers.map(e => ICEServer.fromJSON(e)) : [],
10741
- clientConfiguration: isSet(object.clientConfiguration) ? ClientConfiguration.fromJSON(object.clientConfiguration) : undefined,
10742
- room: isSet(object.room) ? Room$1.fromJSON(object.room) : undefined,
10743
- participant: isSet(object.participant) ? ParticipantInfo.fromJSON(object.participant) : undefined,
10744
- otherParticipants: Array.isArray(object === null || object === void 0 ? void 0 : object.otherParticipants) ? object.otherParticipants.map(e => ParticipantInfo.fromJSON(e)) : []
10808
+ clientConfiguration: isSet(object.clientConfiguration) ? ClientConfiguration.fromJSON(object.clientConfiguration) : undefined
10745
10809
  };
10746
10810
  },
10747
10811
  toJSON(message) {
@@ -10752,23 +10816,16 @@ const ReconnectResponse = {
10752
10816
  obj.iceServers = [];
10753
10817
  }
10754
10818
  message.clientConfiguration !== undefined && (obj.clientConfiguration = message.clientConfiguration ? ClientConfiguration.toJSON(message.clientConfiguration) : undefined);
10755
- message.room !== undefined && (obj.room = message.room ? Room$1.toJSON(message.room) : undefined);
10756
- message.participant !== undefined && (obj.participant = message.participant ? ParticipantInfo.toJSON(message.participant) : undefined);
10757
- if (message.otherParticipants) {
10758
- obj.otherParticipants = message.otherParticipants.map(e => e ? ParticipantInfo.toJSON(e) : undefined);
10759
- } else {
10760
- obj.otherParticipants = [];
10761
- }
10762
10819
  return obj;
10763
10820
  },
10821
+ create(base) {
10822
+ return ReconnectResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10823
+ },
10764
10824
  fromPartial(object) {
10765
- var _a, _b;
10825
+ var _a;
10766
10826
  const message = createBaseReconnectResponse();
10767
10827
  message.iceServers = ((_a = object.iceServers) === null || _a === void 0 ? void 0 : _a.map(e => ICEServer.fromPartial(e))) || [];
10768
10828
  message.clientConfiguration = object.clientConfiguration !== undefined && object.clientConfiguration !== null ? ClientConfiguration.fromPartial(object.clientConfiguration) : undefined;
10769
- message.room = object.room !== undefined && object.room !== null ? Room$1.fromPartial(object.room) : undefined;
10770
- message.participant = object.participant !== undefined && object.participant !== null ? ParticipantInfo.fromPartial(object.participant) : undefined;
10771
- message.otherParticipants = ((_b = object.otherParticipants) === null || _b === void 0 ? void 0 : _b.map(e => ParticipantInfo.fromPartial(e))) || [];
10772
10829
  return message;
10773
10830
  }
10774
10831
  };
@@ -10821,6 +10878,9 @@ const TrackPublishedResponse = {
10821
10878
  message.track !== undefined && (obj.track = message.track ? TrackInfo.toJSON(message.track) : undefined);
10822
10879
  return obj;
10823
10880
  },
10881
+ create(base) {
10882
+ return TrackPublishedResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10883
+ },
10824
10884
  fromPartial(object) {
10825
10885
  var _a;
10826
10886
  const message = createBaseTrackPublishedResponse();
@@ -10869,6 +10929,9 @@ const TrackUnpublishedResponse = {
10869
10929
  message.trackSid !== undefined && (obj.trackSid = message.trackSid);
10870
10930
  return obj;
10871
10931
  },
10932
+ create(base) {
10933
+ return TrackUnpublishedResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10934
+ },
10872
10935
  fromPartial(object) {
10873
10936
  var _a;
10874
10937
  const message = createBaseTrackUnpublishedResponse();
@@ -10925,6 +10988,9 @@ const SessionDescription = {
10925
10988
  message.sdp !== undefined && (obj.sdp = message.sdp);
10926
10989
  return obj;
10927
10990
  },
10991
+ create(base) {
10992
+ return SessionDescription.fromPartial(base !== null && base !== void 0 ? base : {});
10993
+ },
10928
10994
  fromPartial(object) {
10929
10995
  var _a, _b;
10930
10996
  const message = createBaseSessionDescription();
@@ -10977,6 +11043,9 @@ const ParticipantUpdate = {
10977
11043
  }
10978
11044
  return obj;
10979
11045
  },
11046
+ create(base) {
11047
+ return ParticipantUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
11048
+ },
10980
11049
  fromPartial(object) {
10981
11050
  var _a;
10982
11051
  const message = createBaseParticipantUpdate();
@@ -11050,6 +11119,9 @@ const UpdateSubscription = {
11050
11119
  }
11051
11120
  return obj;
11052
11121
  },
11122
+ create(base) {
11123
+ return UpdateSubscription.fromPartial(base !== null && base !== void 0 ? base : {});
11124
+ },
11053
11125
  fromPartial(object) {
11054
11126
  var _a, _b, _c;
11055
11127
  const message = createBaseUpdateSubscription();
@@ -11157,6 +11229,9 @@ const UpdateTrackSettings = {
11157
11229
  message.priority !== undefined && (obj.priority = Math.round(message.priority));
11158
11230
  return obj;
11159
11231
  },
11232
+ create(base) {
11233
+ return UpdateTrackSettings.fromPartial(base !== null && base !== void 0 ? base : {});
11234
+ },
11160
11235
  fromPartial(object) {
11161
11236
  var _a, _b, _c, _d, _e, _f, _g;
11162
11237
  const message = createBaseUpdateTrackSettings();
@@ -11219,6 +11294,9 @@ const LeaveRequest = {
11219
11294
  message.reason !== undefined && (obj.reason = disconnectReasonToJSON(message.reason));
11220
11295
  return obj;
11221
11296
  },
11297
+ create(base) {
11298
+ return LeaveRequest.fromPartial(base !== null && base !== void 0 ? base : {});
11299
+ },
11222
11300
  fromPartial(object) {
11223
11301
  var _a, _b;
11224
11302
  const message = createBaseLeaveRequest();
@@ -11280,6 +11358,9 @@ const UpdateVideoLayers = {
11280
11358
  }
11281
11359
  return obj;
11282
11360
  },
11361
+ create(base) {
11362
+ return UpdateVideoLayers.fromPartial(base !== null && base !== void 0 ? base : {});
11363
+ },
11283
11364
  fromPartial(object) {
11284
11365
  var _a, _b;
11285
11366
  const message = createBaseUpdateVideoLayers();
@@ -11328,6 +11409,9 @@ const UpdateParticipantMetadata = {
11328
11409
  message.metadata !== undefined && (obj.metadata = message.metadata);
11329
11410
  return obj;
11330
11411
  },
11412
+ create(base) {
11413
+ return UpdateParticipantMetadata.fromPartial(base !== null && base !== void 0 ? base : {});
11414
+ },
11331
11415
  fromPartial(object) {
11332
11416
  var _a;
11333
11417
  const message = createBaseUpdateParticipantMetadata();
@@ -11397,6 +11481,9 @@ const ICEServer = {
11397
11481
  message.credential !== undefined && (obj.credential = message.credential);
11398
11482
  return obj;
11399
11483
  },
11484
+ create(base) {
11485
+ return ICEServer.fromPartial(base !== null && base !== void 0 ? base : {});
11486
+ },
11400
11487
  fromPartial(object) {
11401
11488
  var _a, _b, _c;
11402
11489
  const message = createBaseICEServer();
@@ -11450,6 +11537,9 @@ const SpeakersChanged = {
11450
11537
  }
11451
11538
  return obj;
11452
11539
  },
11540
+ create(base) {
11541
+ return SpeakersChanged.fromPartial(base !== null && base !== void 0 ? base : {});
11542
+ },
11453
11543
  fromPartial(object) {
11454
11544
  var _a;
11455
11545
  const message = createBaseSpeakersChanged();
@@ -11497,6 +11587,9 @@ const RoomUpdate = {
11497
11587
  message.room !== undefined && (obj.room = message.room ? Room$1.toJSON(message.room) : undefined);
11498
11588
  return obj;
11499
11589
  },
11590
+ create(base) {
11591
+ return RoomUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
11592
+ },
11500
11593
  fromPartial(object) {
11501
11594
  const message = createBaseRoomUpdate();
11502
11595
  message.room = object.room !== undefined && object.room !== null ? Room$1.fromPartial(object.room) : undefined;
@@ -11561,6 +11654,9 @@ const ConnectionQualityInfo = {
11561
11654
  message.score !== undefined && (obj.score = message.score);
11562
11655
  return obj;
11563
11656
  },
11657
+ create(base) {
11658
+ return ConnectionQualityInfo.fromPartial(base !== null && base !== void 0 ? base : {});
11659
+ },
11564
11660
  fromPartial(object) {
11565
11661
  var _a, _b, _c;
11566
11662
  const message = createBaseConnectionQualityInfo();
@@ -11614,6 +11710,9 @@ const ConnectionQualityUpdate = {
11614
11710
  }
11615
11711
  return obj;
11616
11712
  },
11713
+ create(base) {
11714
+ return ConnectionQualityUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
11715
+ },
11617
11716
  fromPartial(object) {
11618
11717
  var _a;
11619
11718
  const message = createBaseConnectionQualityUpdate();
@@ -11679,6 +11778,9 @@ const StreamStateInfo = {
11679
11778
  message.state !== undefined && (obj.state = streamStateToJSON(message.state));
11680
11779
  return obj;
11681
11780
  },
11781
+ create(base) {
11782
+ return StreamStateInfo.fromPartial(base !== null && base !== void 0 ? base : {});
11783
+ },
11682
11784
  fromPartial(object) {
11683
11785
  var _a, _b, _c;
11684
11786
  const message = createBaseStreamStateInfo();
@@ -11732,6 +11834,9 @@ const StreamStateUpdate = {
11732
11834
  }
11733
11835
  return obj;
11734
11836
  },
11837
+ create(base) {
11838
+ return StreamStateUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
11839
+ },
11735
11840
  fromPartial(object) {
11736
11841
  var _a;
11737
11842
  const message = createBaseStreamStateUpdate();
@@ -11788,6 +11893,9 @@ const SubscribedQuality = {
11788
11893
  message.enabled !== undefined && (obj.enabled = message.enabled);
11789
11894
  return obj;
11790
11895
  },
11896
+ create(base) {
11897
+ return SubscribedQuality.fromPartial(base !== null && base !== void 0 ? base : {});
11898
+ },
11791
11899
  fromPartial(object) {
11792
11900
  var _a, _b;
11793
11901
  const message = createBaseSubscribedQuality();
@@ -11849,6 +11957,9 @@ const SubscribedCodec = {
11849
11957
  }
11850
11958
  return obj;
11851
11959
  },
11960
+ create(base) {
11961
+ return SubscribedCodec.fromPartial(base !== null && base !== void 0 ? base : {});
11962
+ },
11852
11963
  fromPartial(object) {
11853
11964
  var _a, _b;
11854
11965
  const message = createBaseSubscribedCodec();
@@ -11923,6 +12034,9 @@ const SubscribedQualityUpdate = {
11923
12034
  }
11924
12035
  return obj;
11925
12036
  },
12037
+ create(base) {
12038
+ return SubscribedQualityUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
12039
+ },
11926
12040
  fromPartial(object) {
11927
12041
  var _a, _b, _c;
11928
12042
  const message = createBaseSubscribedQualityUpdate();
@@ -12003,6 +12117,9 @@ const TrackPermission = {
12003
12117
  message.participantIdentity !== undefined && (obj.participantIdentity = message.participantIdentity);
12004
12118
  return obj;
12005
12119
  },
12120
+ create(base) {
12121
+ return TrackPermission.fromPartial(base !== null && base !== void 0 ? base : {});
12122
+ },
12006
12123
  fromPartial(object) {
12007
12124
  var _a, _b, _c, _d;
12008
12125
  const message = createBaseTrackPermission();
@@ -12066,6 +12183,9 @@ const SubscriptionPermission = {
12066
12183
  }
12067
12184
  return obj;
12068
12185
  },
12186
+ create(base) {
12187
+ return SubscriptionPermission.fromPartial(base !== null && base !== void 0 ? base : {});
12188
+ },
12069
12189
  fromPartial(object) {
12070
12190
  var _a, _b;
12071
12191
  const message = createBaseSubscriptionPermission();
@@ -12132,6 +12252,9 @@ const SubscriptionPermissionUpdate = {
12132
12252
  message.allowed !== undefined && (obj.allowed = message.allowed);
12133
12253
  return obj;
12134
12254
  },
12255
+ create(base) {
12256
+ return SubscriptionPermissionUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
12257
+ },
12135
12258
  fromPartial(object) {
12136
12259
  var _a, _b, _c;
12137
12260
  const message = createBaseSubscriptionPermissionUpdate();
@@ -12225,6 +12348,9 @@ const SyncState = {
12225
12348
  message.offer !== undefined && (obj.offer = message.offer ? SessionDescription.toJSON(message.offer) : undefined);
12226
12349
  return obj;
12227
12350
  },
12351
+ create(base) {
12352
+ return SyncState.fromPartial(base !== null && base !== void 0 ? base : {});
12353
+ },
12228
12354
  fromPartial(object) {
12229
12355
  var _a, _b;
12230
12356
  const message = createBaseSyncState();
@@ -12294,6 +12420,9 @@ const DataChannelInfo = {
12294
12420
  message.target !== undefined && (obj.target = signalTargetToJSON(message.target));
12295
12421
  return obj;
12296
12422
  },
12423
+ create(base) {
12424
+ return DataChannelInfo.fromPartial(base !== null && base !== void 0 ? base : {});
12425
+ },
12297
12426
  fromPartial(object) {
12298
12427
  var _a, _b, _c;
12299
12428
  const message = createBaseDataChannelInfo();
@@ -12311,21 +12440,23 @@ function createBaseSimulateScenario() {
12311
12440
  const SimulateScenario = {
12312
12441
  encode(message) {
12313
12442
  let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
12314
- var _a, _b, _c, _d, _e;
12315
- if (((_a = message.scenario) === null || _a === void 0 ? void 0 : _a.$case) === "speakerUpdate") {
12316
- writer.uint32(8).int32(message.scenario.speakerUpdate);
12317
- }
12318
- if (((_b = message.scenario) === null || _b === void 0 ? void 0 : _b.$case) === "nodeFailure") {
12319
- writer.uint32(16).bool(message.scenario.nodeFailure);
12320
- }
12321
- if (((_c = message.scenario) === null || _c === void 0 ? void 0 : _c.$case) === "migration") {
12322
- writer.uint32(24).bool(message.scenario.migration);
12323
- }
12324
- if (((_d = message.scenario) === null || _d === void 0 ? void 0 : _d.$case) === "serverLeave") {
12325
- writer.uint32(32).bool(message.scenario.serverLeave);
12326
- }
12327
- if (((_e = message.scenario) === null || _e === void 0 ? void 0 : _e.$case) === "switchCandidateProtocol") {
12328
- writer.uint32(40).int32(message.scenario.switchCandidateProtocol);
12443
+ var _a;
12444
+ switch ((_a = message.scenario) === null || _a === void 0 ? void 0 : _a.$case) {
12445
+ case "speakerUpdate":
12446
+ writer.uint32(8).int32(message.scenario.speakerUpdate);
12447
+ break;
12448
+ case "nodeFailure":
12449
+ writer.uint32(16).bool(message.scenario.nodeFailure);
12450
+ break;
12451
+ case "migration":
12452
+ writer.uint32(24).bool(message.scenario.migration);
12453
+ break;
12454
+ case "serverLeave":
12455
+ writer.uint32(32).bool(message.scenario.serverLeave);
12456
+ break;
12457
+ case "switchCandidateProtocol":
12458
+ writer.uint32(40).int32(message.scenario.switchCandidateProtocol);
12459
+ break;
12329
12460
  }
12330
12461
  return writer;
12331
12462
  },
@@ -12403,6 +12534,9 @@ const SimulateScenario = {
12403
12534
  ((_j = message.scenario) === null || _j === void 0 ? void 0 : _j.$case) === "switchCandidateProtocol" && (obj.switchCandidateProtocol = ((_k = message.scenario) === null || _k === void 0 ? void 0 : _k.switchCandidateProtocol) !== undefined ? candidateProtocolToJSON((_l = message.scenario) === null || _l === void 0 ? void 0 : _l.switchCandidateProtocol) : undefined);
12404
12535
  return obj;
12405
12536
  },
12537
+ create(base) {
12538
+ return SimulateScenario.fromPartial(base !== null && base !== void 0 ? base : {});
12539
+ },
12406
12540
  fromPartial(object) {
12407
12541
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
12408
12542
  const message = createBaseSimulateScenario();
@@ -12488,6 +12622,9 @@ const Ping = {
12488
12622
  message.rtt !== undefined && (obj.rtt = Math.round(message.rtt));
12489
12623
  return obj;
12490
12624
  },
12625
+ create(base) {
12626
+ return Ping.fromPartial(base !== null && base !== void 0 ? base : {});
12627
+ },
12491
12628
  fromPartial(object) {
12492
12629
  var _a, _b;
12493
12630
  const message = createBasePing();
@@ -12545,6 +12682,9 @@ const Pong = {
12545
12682
  message.timestamp !== undefined && (obj.timestamp = Math.round(message.timestamp));
12546
12683
  return obj;
12547
12684
  },
12685
+ create(base) {
12686
+ return Pong.fromPartial(base !== null && base !== void 0 ? base : {});
12687
+ },
12548
12688
  fromPartial(object) {
12549
12689
  var _a, _b;
12550
12690
  const message = createBasePong();
@@ -12809,7 +12949,7 @@ var RoomEvent;
12809
12949
  * Data packets provides the ability to use LiveKit to send/receive arbitrary payloads.
12810
12950
  * All participants in the room will receive the messages sent to the room.
12811
12951
  *
12812
- * args: (payload: Uint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]])
12952
+ * args: (payload: Uint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]], topic?: string)
12813
12953
  */
12814
12954
  RoomEvent["DataReceived"] = "dataReceived";
12815
12955
  /**
@@ -13800,10 +13940,10 @@ var uaParser = {
13800
13940
  })(uaParser, uaParserExports);
13801
13941
  var UAParser = uaParserExports;
13802
13942
 
13803
- var version$1 = "1.6.6";
13943
+ var version$1 = "1.6.8";
13804
13944
 
13805
13945
  const version = version$1;
13806
- const protocolVersion = 8;
13946
+ const protocolVersion = 9;
13807
13947
 
13808
13948
  function mergeDefaultOptions(options, audioDefaults, videoDefaults) {
13809
13949
  const opts = _objectSpread2({}, options);
@@ -14781,7 +14921,8 @@ class Track extends eventsExports.EventEmitter {
14781
14921
  this.attachedElements = [];
14782
14922
  this.isMuted = false;
14783
14923
  /**
14784
- * indicates current state of stream
14924
+ * indicates current state of stream, it'll indicate `paused` if the track
14925
+ * has been paused by congestion controller
14785
14926
  */
14786
14927
  this.streamState = Track.StreamState.Active;
14787
14928
  this._currentBitrate = 0;
@@ -16115,9 +16256,6 @@ class RemoteVideoTrack extends RemoteTrack {
16115
16256
  this.updateDimensions();
16116
16257
  }, REACTION_DELAY);
16117
16258
  this.adaptiveStreamSettings = adaptiveStreamSettings;
16118
- if (this.isAdaptiveStream) {
16119
- this.streamState = Track.StreamState.Paused;
16120
- }
16121
16259
  }
16122
16260
  get isAdaptiveStream() {
16123
16261
  return this.adaptiveStreamSettings !== undefined;
@@ -17023,8 +17161,8 @@ function sortPresets(presets) {
17023
17161
  }
17024
17162
 
17025
17163
  class RemoteTrackPublication extends TrackPublication {
17026
- constructor(kind, id, name, autoSubscribe) {
17027
- super(kind, id, name);
17164
+ constructor(kind, ti, autoSubscribe) {
17165
+ super(kind, ti.sid, ti.name);
17028
17166
  this.track = undefined;
17029
17167
  /** @internal */
17030
17168
  this.allowed = true;
@@ -17049,6 +17187,7 @@ class RemoteTrackPublication extends TrackPublication {
17049
17187
  this.emitTrackUpdate();
17050
17188
  };
17051
17189
  this.subscribed = autoSubscribe;
17190
+ this.updateInfo(ti);
17052
17191
  }
17053
17192
  /**
17054
17193
  * Subscribe or unsubscribe to this remote track
@@ -17415,12 +17554,12 @@ class RemoteParticipant extends Participant {
17415
17554
  if (!kind) {
17416
17555
  return;
17417
17556
  }
17418
- publication = new RemoteTrackPublication(kind, ti.sid, ti.name, (_a = this.signalClient.connectOptions) === null || _a === void 0 ? void 0 : _a.autoSubscribe);
17557
+ publication = new RemoteTrackPublication(kind, ti, (_a = this.signalClient.connectOptions) === null || _a === void 0 ? void 0 : _a.autoSubscribe);
17419
17558
  publication.updateInfo(ti);
17420
17559
  newTracks.set(ti.sid, publication);
17421
17560
  const existingTrackOfSource = Array.from(this.tracks.values()).find(publishedTrack => publishedTrack.source === (publication === null || publication === void 0 ? void 0 : publication.source));
17422
17561
  if (existingTrackOfSource && publication.source !== Track.Source.Unknown) {
17423
- livekitLogger.warn("received a second track publication for ".concat(this.identity, " with the same source: ").concat(publication.source), {
17562
+ livekitLogger.debug("received a second track publication for ".concat(this.identity, " with the same source: ").concat(publication.source), {
17424
17563
  oldTrack: existingTrackOfSource,
17425
17564
  newTrack: publication,
17426
17565
  participant: this,
@@ -17516,8 +17655,20 @@ class LocalParticipant extends Participant {
17516
17655
  constructor(sid, identity, engine, options) {
17517
17656
  super(sid, identity);
17518
17657
  this.pendingPublishing = new Set();
17658
+ this.pendingPublishPromises = new Map();
17519
17659
  this.participantTrackPermissions = [];
17520
17660
  this.allParticipantsAllowedToSubscribe = true;
17661
+ this.handleReconnecting = () => {
17662
+ if (!this.reconnectFuture) {
17663
+ this.reconnectFuture = new Future();
17664
+ }
17665
+ };
17666
+ this.handleReconnected = () => {
17667
+ var _a, _b;
17668
+ (_b = (_a = this.reconnectFuture) === null || _a === void 0 ? void 0 : _a.resolve) === null || _b === void 0 ? void 0 : _b.call(_a);
17669
+ this.reconnectFuture = undefined;
17670
+ this.updateTrackSubscriptionPermissions();
17671
+ };
17521
17672
  this.updateTrackSubscriptionPermissions = () => {
17522
17673
  livekitLogger.debug('updating track subscription permissions', {
17523
17674
  allParticipantsAllowed: this.allParticipantsAllowedToSubscribe,
@@ -17696,7 +17847,7 @@ class LocalParticipant extends Participant {
17696
17847
  };
17697
17848
  this.engine.client.onSubscribedQualityUpdate = this.handleSubscribedQualityUpdate;
17698
17849
  this.engine.client.onLocalTrackUnpublished = this.handleLocalTrackUnpublished;
17699
- this.engine.on(EngineEvent.Connected, this.updateTrackSubscriptionPermissions).on(EngineEvent.Restarted, this.updateTrackSubscriptionPermissions).on(EngineEvent.Resumed, this.updateTrackSubscriptionPermissions);
17850
+ this.engine.on(EngineEvent.Connected, this.handleReconnected).on(EngineEvent.Restarted, this.handleReconnected).on(EngineEvent.Resumed, this.handleReconnected).on(EngineEvent.Restarting, this.handleReconnecting).on(EngineEvent.Resuming, this.handleReconnecting);
17700
17851
  }
17701
17852
  /**
17702
17853
  * Enable or disable a participant's camera track.
@@ -17906,7 +18057,12 @@ class LocalParticipant extends Participant {
17906
18057
  }
17907
18058
  const stream = await navigator.mediaDevices.getDisplayMedia({
17908
18059
  audio: (_a = options.audio) !== null && _a !== void 0 ? _a : false,
17909
- video: videoConstraints
18060
+ video: videoConstraints,
18061
+ // @ts-expect-error support for experimental display media features
18062
+ controller: options.controller,
18063
+ selfBrowserSurface: options.selfBrowserSurface,
18064
+ surfaceSwitching: options.surfaceSwitching,
18065
+ systemAudio: options.systemAudio
17910
18066
  });
17911
18067
  const tracks = stream.getVideoTracks();
17912
18068
  if (tracks.length === 0) {
@@ -17928,7 +18084,11 @@ class LocalParticipant extends Participant {
17928
18084
  * @param options
17929
18085
  */
17930
18086
  async publishTrack(track, options) {
17931
- var _a, _b, _c, _d, _e;
18087
+ var _a, _b, _c;
18088
+ await ((_a = this.reconnectFuture) === null || _a === void 0 ? void 0 : _a.promise);
18089
+ if (track instanceof LocalTrack && this.pendingPublishPromises.has(track)) {
18090
+ await this.pendingPublishPromises.get(track);
18091
+ }
17932
18092
  // convert raw media track into audio or video track
17933
18093
  if (track instanceof MediaStreamTrack) {
17934
18094
  switch (track.kind) {
@@ -17942,6 +18102,20 @@ class LocalParticipant extends Participant {
17942
18102
  throw new TrackInvalidError("unsupported MediaStreamTrack kind ".concat(track.kind));
17943
18103
  }
17944
18104
  }
18105
+ // is it already published? if so skip
18106
+ let existingPublication;
18107
+ this.tracks.forEach(publication => {
18108
+ if (!publication.track) {
18109
+ return;
18110
+ }
18111
+ if (publication.track === track) {
18112
+ existingPublication = publication;
18113
+ }
18114
+ });
18115
+ if (existingPublication) {
18116
+ livekitLogger.warn('track has already been published, skipping');
18117
+ return existingPublication;
18118
+ }
17945
18119
  const isStereo = (options === null || options === void 0 ? void 0 : options.forceStereo) || 'channelCount' in track.mediaStreamTrack.getSettings() &&
17946
18120
  // @ts-ignore `channelCount` on getSettings() is currently only available for Safari, but is generally the best way to determine a stereo track https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings/channelCount
17947
18121
  track.mediaStreamTrack.getSettings().channelCount === 2 || track.mediaStreamTrack.getConstraints().channelCount === 2;
@@ -17953,23 +18127,29 @@ class LocalParticipant extends Participant {
17953
18127
  if (options.dtx === undefined) {
17954
18128
  livekitLogger.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.");
17955
18129
  }
17956
- (_a = options.dtx) !== null && _a !== void 0 ? _a : options.dtx = false;
18130
+ if (options.red === undefined) {
18131
+ livekitLogger.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work.");
18132
+ }
18133
+ (_b = options.dtx) !== null && _b !== void 0 ? _b : options.dtx = false;
18134
+ (_c = options.red) !== null && _c !== void 0 ? _c : options.red = false;
17957
18135
  }
17958
18136
  const opts = _objectSpread2(_objectSpread2({}, this.roomOptions.publishDefaults), options);
17959
- // is it already published? if so skip
17960
- let existingPublication;
17961
- this.tracks.forEach(publication => {
17962
- if (!publication.track) {
17963
- return;
17964
- }
17965
- if (publication.track === track) {
17966
- existingPublication = publication;
17967
- }
17968
- });
17969
- if (existingPublication) return existingPublication;
17970
18137
  if (opts.source) {
17971
18138
  track.source = opts.source;
17972
18139
  }
18140
+ const publishPromise = this.publish(track, opts, options, isStereo);
18141
+ this.pendingPublishPromises.set(track, publishPromise);
18142
+ try {
18143
+ const publication = await publishPromise;
18144
+ return publication;
18145
+ } catch (e) {
18146
+ throw e;
18147
+ } finally {
18148
+ this.pendingPublishPromises.delete(track);
18149
+ }
18150
+ }
18151
+ async publish(track, opts, options, isStereo) {
18152
+ var _a, _b, _c, _d;
17973
18153
  const existingTrackOfSource = Array.from(this.tracks.values()).find(publishedTrack => track instanceof LocalTrack && publishedTrack.source === track.source);
17974
18154
  if (existingTrackOfSource && track.source !== Track.Source.Unknown) {
17975
18155
  try {
@@ -18011,9 +18191,9 @@ class LocalParticipant extends Participant {
18011
18191
  type: Track.kindToProto(track.kind),
18012
18192
  muted: track.isMuted,
18013
18193
  source: Track.sourceToProto(track.source),
18014
- disableDtx: !((_b = opts.dtx) !== null && _b !== void 0 ? _b : true),
18194
+ disableDtx: !((_a = opts.dtx) !== null && _a !== void 0 ? _a : true),
18015
18195
  stereo: isStereo,
18016
- disableRed: !((_c = opts.red) !== null && _c !== void 0 ? _c : true)
18196
+ disableRed: !((_b = opts.red) !== null && _b !== void 0 ? _b : true)
18017
18197
  });
18018
18198
  // compute encodings and layers for video
18019
18199
  let encodings;
@@ -18036,7 +18216,7 @@ class LocalParticipant extends Participant {
18036
18216
  if (track instanceof LocalVideoTrack) {
18037
18217
  if ((opts === null || opts === void 0 ? void 0 : opts.videoCodec) === 'av1') {
18038
18218
  // set scalabilityMode to 'L3T3' by default
18039
- opts.scalabilityMode = (_d = opts.scalabilityMode) !== null && _d !== void 0 ? _d : 'L3T3';
18219
+ opts.scalabilityMode = (_c = opts.scalabilityMode) !== null && _c !== void 0 ? _c : 'L3T3';
18040
18220
  }
18041
18221
  // set up backup
18042
18222
  if (opts.videoCodec && opts.backupCodec && opts.videoCodec !== opts.backupCodec.codec) {
@@ -18078,7 +18258,7 @@ class LocalParticipant extends Participant {
18078
18258
  });
18079
18259
  // store RTPSender
18080
18260
  track.sender = await this.engine.createSender(track, opts, encodings);
18081
- if (track.codec === 'av1' && encodings && ((_e = encodings[0]) === null || _e === void 0 ? void 0 : _e.maxBitrate)) {
18261
+ if (track.codec === 'av1' && encodings && ((_d = encodings[0]) === null || _d === void 0 ? void 0 : _d.maxBitrate)) {
18082
18262
  this.engine.publisher.setTrackCodecBitrate(req.cid, track.codec, encodings[0].maxBitrate / 1000);
18083
18263
  }
18084
18264
  this.engine.negotiate();
@@ -18174,13 +18354,20 @@ class LocalParticipant extends Participant {
18174
18354
  if (stopOnUnpublish) {
18175
18355
  track.stop();
18176
18356
  }
18177
- if (this.engine.publisher && this.engine.publisher.pc.connectionState !== 'closed' && track.sender) {
18357
+ let negotiationNeeded = false;
18358
+ const trackSender = track.sender;
18359
+ track.sender = undefined;
18360
+ if (this.engine.publisher && this.engine.publisher.pc.connectionState !== 'closed' && trackSender) {
18178
18361
  try {
18179
- this.engine.removeTrack(track.sender);
18362
+ if (this.engine.removeTrack(trackSender)) {
18363
+ negotiationNeeded = true;
18364
+ }
18180
18365
  if (track instanceof LocalVideoTrack) {
18181
18366
  for (const [, trackInfo] of track.simulcastCodecs) {
18182
18367
  if (trackInfo.sender) {
18183
- this.engine.removeTrack(trackInfo.sender);
18368
+ if (this.engine.removeTrack(trackInfo.sender)) {
18369
+ negotiationNeeded = true;
18370
+ }
18184
18371
  trackInfo.sender = undefined;
18185
18372
  }
18186
18373
  }
@@ -18191,11 +18378,8 @@ class LocalParticipant extends Participant {
18191
18378
  error: e,
18192
18379
  method: 'unpublishTrack'
18193
18380
  });
18194
- } finally {
18195
- await this.engine.negotiate();
18196
18381
  }
18197
18382
  }
18198
- track.sender = undefined;
18199
18383
  // remove from our maps
18200
18384
  this.tracks.delete(publication.trackSid);
18201
18385
  switch (publication.kind) {
@@ -18208,6 +18392,9 @@ class LocalParticipant extends Participant {
18208
18392
  }
18209
18393
  this.emit(ParticipantEvent.LocalTrackUnpublished, publication);
18210
18394
  publication.setTrack(undefined);
18395
+ if (negotiationNeeded) {
18396
+ await this.engine.negotiate();
18397
+ }
18211
18398
  return publication;
18212
18399
  }
18213
18400
  async unpublishTracks(tracks) {
@@ -18230,25 +18417,17 @@ class LocalParticipant extends Participant {
18230
18417
  await this.publishTrack(track, pub.options);
18231
18418
  }));
18232
18419
  }
18233
- /**
18234
- * Publish a new data payload to the room. Data will be forwarded to each
18235
- * participant in the room if the destination argument is empty
18236
- *
18237
- * @param data Uint8Array of the payload. To send string data, use TextEncoder.encode
18238
- * @param kind whether to send this as reliable or lossy.
18239
- * For data that you need delivery guarantee (such as chat messages), use Reliable.
18240
- * For data that should arrive as quickly as possible, but you are ok with dropped
18241
- * packets, use Lossy.
18242
- * @param destination the participants who will receive the message
18243
- */
18244
- async publishData(data, kind, destination) {
18245
- const dest = [];
18420
+ async publishData(data, kind) {
18421
+ let publishOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
18422
+ const destination = Array.isArray(publishOptions) ? publishOptions : publishOptions === null || publishOptions === void 0 ? void 0 : publishOptions.destination;
18423
+ const destinationSids = [];
18424
+ const topic = !Array.isArray(publishOptions) ? publishOptions.topic : undefined;
18246
18425
  if (destination !== undefined) {
18247
18426
  destination.forEach(val => {
18248
18427
  if (val instanceof RemoteParticipant) {
18249
- dest.push(val.sid);
18428
+ destinationSids.push(val.sid);
18250
18429
  } else {
18251
- dest.push(val);
18430
+ destinationSids.push(val);
18252
18431
  }
18253
18432
  });
18254
18433
  }
@@ -18259,7 +18438,8 @@ class LocalParticipant extends Participant {
18259
18438
  user: {
18260
18439
  participantSid: this.sid,
18261
18440
  payload: data,
18262
- destinationSids: dest
18441
+ destinationSids: destinationSids,
18442
+ topic
18263
18443
  }
18264
18444
  }
18265
18445
  };
@@ -19757,6 +19937,8 @@ class PCTransport extends eventsExports {
19757
19937
  });
19758
19938
  }
19759
19939
  close() {
19940
+ this.pc.onconnectionstatechange = null;
19941
+ this.pc.oniceconnectionstatechange = null;
19760
19942
  this.pc.close();
19761
19943
  }
19762
19944
  async setMungedLocalDescription(sd, munged) {
@@ -19875,9 +20057,7 @@ class RTCEngine extends eventsExports.EventEmitter {
19875
20057
  return this._isClosed;
19876
20058
  }
19877
20059
  constructor(options) {
19878
- var _this;
19879
20060
  super();
19880
- _this = this;
19881
20061
  this.options = options;
19882
20062
  this.rtcConfig = {};
19883
20063
  this.peerConnectionTimeout = roomConnectOptionDefaults.peerConnectionTimeout;
@@ -19896,6 +20076,7 @@ class RTCEngine extends eventsExports.EventEmitter {
19896
20076
  this.joinAttempts = 0;
19897
20077
  /** specifies how often an initial join connection is allowed to retry */
19898
20078
  this.maxJoinAttempts = 1;
20079
+ this.shouldFailNext = false;
19899
20080
  this.handleDataChannel = async _ref => {
19900
20081
  let {
19901
20082
  channel
@@ -19948,26 +20129,24 @@ class RTCEngine extends eventsExports.EventEmitter {
19948
20129
  // websocket reconnect behavior. if websocket is interrupted, and the PeerConnection
19949
20130
  // continues to work, we can reconnect to websocket to continue the session
19950
20131
  // after a number of retries, we'll close and give up permanently
19951
- this.handleDisconnect = function (connection) {
19952
- let signalEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
19953
- let disconnectReason = arguments.length > 2 ? arguments[2] : undefined;
19954
- if (_this._isClosed) {
20132
+ this.handleDisconnect = (connection, disconnectReason) => {
20133
+ if (this._isClosed) {
19955
20134
  return;
19956
20135
  }
19957
20136
  livekitLogger.warn("".concat(connection, " disconnected"));
19958
- if (_this.reconnectAttempts === 0) {
20137
+ if (this.reconnectAttempts === 0) {
19959
20138
  // only reset start time on the first try
19960
- _this.reconnectStart = Date.now();
20139
+ this.reconnectStart = Date.now();
19961
20140
  }
19962
20141
  const disconnect = duration => {
19963
- livekitLogger.warn("could not recover connection after ".concat(_this.reconnectAttempts, " attempts, ").concat(duration, "ms. giving up"));
19964
- _this.emit(EngineEvent.Disconnected);
19965
- _this.close();
20142
+ livekitLogger.warn("could not recover connection after ".concat(this.reconnectAttempts, " attempts, ").concat(duration, "ms. giving up"));
20143
+ this.emit(EngineEvent.Disconnected);
20144
+ this.close();
19966
20145
  };
19967
- const duration = Date.now() - _this.reconnectStart;
19968
- let delay = _this.getNextRetryDelay({
20146
+ const duration = Date.now() - this.reconnectStart;
20147
+ let delay = this.getNextRetryDelay({
19969
20148
  elapsedMs: duration,
19970
- retryCount: _this.reconnectAttempts
20149
+ retryCount: this.reconnectAttempts
19971
20150
  });
19972
20151
  if (delay === null) {
19973
20152
  disconnect(duration);
@@ -19977,14 +20156,14 @@ class RTCEngine extends eventsExports.EventEmitter {
19977
20156
  delay = 0;
19978
20157
  }
19979
20158
  livekitLogger.debug("reconnecting in ".concat(delay, "ms"));
19980
- _this.clearReconnectTimeout();
19981
- _this.reconnectTimeout = CriticalTimers.setTimeout(() => _this.attemptReconnect(signalEvents, disconnectReason), delay);
20159
+ this.clearReconnectTimeout();
20160
+ this.reconnectTimeout = CriticalTimers.setTimeout(() => this.attemptReconnect(disconnectReason), delay);
19982
20161
  };
19983
20162
  this.handleBrowserOnLine = () => {
19984
20163
  // in case the engine is currently reconnecting, attempt a reconnect immediately after the browser state has changed to 'onLine'
19985
20164
  if (this.client.isReconnecting) {
19986
20165
  this.clearReconnectTimeout();
19987
- this.attemptReconnect(true, ReconnectReason.REASON_SIGNAL_DISCONNECTED);
20166
+ this.attemptReconnect(ReconnectReason.RR_SIGNAL_DISCONNECTED);
19988
20167
  }
19989
20168
  };
19990
20169
  this.client = new SignalClient();
@@ -20083,6 +20262,12 @@ class RTCEngine extends eventsExports.EventEmitter {
20083
20262
  this.client.sendAddTrack(req);
20084
20263
  });
20085
20264
  }
20265
+ /**
20266
+ * Removes sender from PeerConnection, returning true if it was removed successfully
20267
+ * and a negotiation is necessary
20268
+ * @param sender
20269
+ * @returns
20270
+ */
20086
20271
  removeTrack(sender) {
20087
20272
  var _a;
20088
20273
  if (sender.track && this.pendingTrackResolvers[sender.track.id]) {
@@ -20096,12 +20281,14 @@ class RTCEngine extends eventsExports.EventEmitter {
20096
20281
  }
20097
20282
  try {
20098
20283
  (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.pc.removeTrack(sender);
20284
+ return true;
20099
20285
  } catch (e) {
20100
20286
  livekitLogger.warn('failed to remove track', {
20101
20287
  error: e,
20102
20288
  method: 'removeTrack'
20103
20289
  });
20104
20290
  }
20291
+ return false;
20105
20292
  }
20106
20293
  updateMuteStatus(trackSid, muted) {
20107
20294
  this.client.sendMuteTrack(trackSid, muted);
@@ -20110,8 +20297,11 @@ class RTCEngine extends eventsExports.EventEmitter {
20110
20297
  var _a;
20111
20298
  return (_a = this.reliableDCSub) === null || _a === void 0 ? void 0 : _a.readyState;
20112
20299
  }
20113
- get connectedServerAddress() {
20114
- return this.connectedServerAddr;
20300
+ async getConnectedServerAddress() {
20301
+ if (this.primaryPC === undefined) {
20302
+ return undefined;
20303
+ }
20304
+ return getConnectedAddress(this.primaryPC);
20115
20305
  }
20116
20306
  configure(joinResponse) {
20117
20307
  var _a;
@@ -20149,13 +20339,6 @@ class RTCEngine extends eventsExports.EventEmitter {
20149
20339
  primaryPC.onconnectionstatechange = async () => {
20150
20340
  livekitLogger.debug("primary PC state changed ".concat(primaryPC.connectionState));
20151
20341
  if (primaryPC.connectionState === 'connected') {
20152
- try {
20153
- this.connectedServerAddr = await getConnectedAddress(primaryPC);
20154
- } catch (e) {
20155
- livekitLogger.warn('could not get connected server address', {
20156
- error: e
20157
- });
20158
- }
20159
20342
  const shouldEmit = this.pcState === PCState.New;
20160
20343
  this.pcState = PCState.Connected;
20161
20344
  if (shouldEmit) {
@@ -20165,7 +20348,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20165
20348
  // on Safari, PeerConnection will switch to 'disconnected' during renegotiation
20166
20349
  if (this.pcState === PCState.Connected) {
20167
20350
  this.pcState = PCState.Disconnected;
20168
- this.handleDisconnect('primary peerconnection', false, subscriberPrimary ? ReconnectReason.REASON_SUBSCRIBER_FAILED : ReconnectReason.REASON_PUBLISHER_FAILED);
20351
+ this.handleDisconnect('primary peerconnection', subscriberPrimary ? ReconnectReason.RR_SUBSCRIBER_FAILED : ReconnectReason.RR_PUBLISHER_FAILED);
20169
20352
  }
20170
20353
  }
20171
20354
  };
@@ -20173,7 +20356,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20173
20356
  livekitLogger.debug("secondary PC state changed ".concat(secondaryPC.connectionState));
20174
20357
  // also reconnect if secondary peerconnection fails
20175
20358
  if (secondaryPC.connectionState === 'failed') {
20176
- this.handleDisconnect('secondary peerconnection', false, subscriberPrimary ? ReconnectReason.REASON_PUBLISHER_FAILED : ReconnectReason.REASON_SUBSCRIBER_FAILED);
20359
+ this.handleDisconnect('secondary peerconnection', subscriberPrimary ? ReconnectReason.RR_PUBLISHER_FAILED : ReconnectReason.RR_SUBSCRIBER_FAILED);
20177
20360
  }
20178
20361
  };
20179
20362
  this.subscriber.pc.ontrack = ev => {
@@ -20236,7 +20419,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20236
20419
  this.token = token;
20237
20420
  };
20238
20421
  this.client.onClose = () => {
20239
- this.handleDisconnect('signal', false, ReconnectReason.REASON_SIGNAL_DISCONNECTED);
20422
+ this.handleDisconnect('signal', ReconnectReason.RR_SIGNAL_DISCONNECTED);
20240
20423
  };
20241
20424
  this.client.onLeave = leave => {
20242
20425
  if (leave === null || leave === void 0 ? void 0 : leave.canReconnect) {
@@ -20410,9 +20593,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20410
20593
  }
20411
20594
  return this.publisher.pc.addTrack(track);
20412
20595
  }
20413
- async attemptReconnect() {
20414
- let signalEvents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
20415
- let reason = arguments.length > 1 ? arguments[1] : undefined;
20596
+ async attemptReconnect(reason) {
20416
20597
  var _a, _b, _c;
20417
20598
  if (this._isClosed) {
20418
20599
  return;
@@ -20430,17 +20611,15 @@ class RTCEngine extends eventsExports.EventEmitter {
20430
20611
  try {
20431
20612
  this.attemptingReconnect = true;
20432
20613
  if (this.fullReconnectOnNext) {
20433
- await this.restartConnection(signalEvents);
20614
+ await this.restartConnection();
20434
20615
  } else {
20435
- await this.resumeConnection(signalEvents, reason);
20616
+ await this.resumeConnection(reason);
20436
20617
  }
20437
20618
  this.clearPendingReconnect();
20438
20619
  this.fullReconnectOnNext = false;
20439
20620
  } catch (e) {
20440
20621
  this.reconnectAttempts += 1;
20441
- let reconnectRequired = false;
20442
20622
  let recoverable = true;
20443
- let requireSignalEvents = false;
20444
20623
  if (e instanceof UnexpectedConnectionState) {
20445
20624
  livekitLogger.debug('received unrecoverable error', {
20446
20625
  error: e
@@ -20449,16 +20628,10 @@ class RTCEngine extends eventsExports.EventEmitter {
20449
20628
  recoverable = false;
20450
20629
  } else if (!(e instanceof SignalReconnectError)) {
20451
20630
  // cannot resume
20452
- reconnectRequired = true;
20453
- }
20454
- // when we flip from resume to reconnect
20455
- // we need to fire the right reconnecting events
20456
- if (reconnectRequired && !this.fullReconnectOnNext) {
20457
20631
  this.fullReconnectOnNext = true;
20458
- requireSignalEvents = true;
20459
20632
  }
20460
20633
  if (recoverable) {
20461
- this.handleDisconnect('reconnect', requireSignalEvents, ReconnectReason.REASON_UNKOWN);
20634
+ this.handleDisconnect('reconnect', ReconnectReason.RR_UNKOWN);
20462
20635
  } else {
20463
20636
  livekitLogger.info("could not recover connection after ".concat(this.reconnectAttempts, " attempts, ").concat(Date.now() - this.reconnectStart, "ms. giving up"));
20464
20637
  this.emit(EngineEvent.Disconnected);
@@ -20480,16 +20653,13 @@ class RTCEngine extends eventsExports.EventEmitter {
20480
20653
  return null;
20481
20654
  }
20482
20655
  async restartConnection() {
20483
- let emitRestarting = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
20484
20656
  var _a, _b;
20485
20657
  if (!this.url || !this.token) {
20486
20658
  // permanent failure, don't attempt reconnection
20487
20659
  throw new UnexpectedConnectionState('could not reconnect, url or token not saved');
20488
20660
  }
20489
20661
  livekitLogger.info("reconnecting, attempt: ".concat(this.reconnectAttempts));
20490
- if (emitRestarting || this.reconnectAttempts === 0) {
20491
- this.emit(EngineEvent.Restarting);
20492
- }
20662
+ this.emit(EngineEvent.Restarting);
20493
20663
  if (this.client.isConnected) {
20494
20664
  await this.client.sendLeave();
20495
20665
  }
@@ -20509,14 +20679,16 @@ class RTCEngine extends eventsExports.EventEmitter {
20509
20679
  } catch (e) {
20510
20680
  throw new SignalReconnectError();
20511
20681
  }
20682
+ if (this.shouldFailNext) {
20683
+ this.shouldFailNext = false;
20684
+ throw new Error('simulated failure');
20685
+ }
20512
20686
  await this.waitForPCConnected();
20513
20687
  this.client.setReconnected();
20514
20688
  // reconnect success
20515
20689
  this.emit(EngineEvent.Restarted, joinResponse);
20516
20690
  }
20517
- async resumeConnection() {
20518
- let emitResuming = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
20519
- let reason = arguments.length > 1 ? arguments[1] : undefined;
20691
+ async resumeConnection(reason) {
20520
20692
  var _a;
20521
20693
  if (!this.url || !this.token) {
20522
20694
  // permanent failure, don't attempt reconnection
@@ -20527,9 +20699,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20527
20699
  throw new UnexpectedConnectionState('publisher and subscriber connections unset');
20528
20700
  }
20529
20701
  livekitLogger.info("resuming signal connection, attempt ".concat(this.reconnectAttempts));
20530
- if (emitResuming || this.reconnectAttempts === 0) {
20531
- this.emit(EngineEvent.Resuming);
20532
- }
20702
+ this.emit(EngineEvent.Resuming);
20533
20703
  try {
20534
20704
  const res = await this.client.reconnect(this.url, this.token, this.participantSid, reason);
20535
20705
  if (res) {
@@ -20545,6 +20715,10 @@ class RTCEngine extends eventsExports.EventEmitter {
20545
20715
  throw new SignalReconnectError(message);
20546
20716
  }
20547
20717
  this.emit(EngineEvent.SignalResumed);
20718
+ if (this.shouldFailNext) {
20719
+ this.shouldFailNext = false;
20720
+ throw new Error('simulated failure');
20721
+ }
20548
20722
  this.subscriber.restartingIce = true;
20549
20723
  // only restart publisher if it's needed
20550
20724
  if (this.hasPublished) {
@@ -20578,13 +20752,6 @@ class RTCEngine extends eventsExports.EventEmitter {
20578
20752
  // manually
20579
20753
  now - startTime > minReconnectWait && ((_a = this.primaryPC) === null || _a === void 0 ? void 0 : _a.connectionState) === 'connected') {
20580
20754
  this.pcState = PCState.Connected;
20581
- try {
20582
- this.connectedServerAddr = await getConnectedAddress(this.primaryPC);
20583
- } catch (e) {
20584
- livekitLogger.warn('could not get connected server address', {
20585
- error: e
20586
- });
20587
- }
20588
20755
  }
20589
20756
  if (this.pcState === PCState.Connected) {
20590
20757
  return;
@@ -20656,7 +20823,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20656
20823
  this.on(EngineEvent.Closing, handleClosed);
20657
20824
  const negotiationTimeout = setTimeout(() => {
20658
20825
  reject('negotiation timed out');
20659
- this.handleDisconnect('negotiation', false, ReconnectReason.REASON_SIGNAL_DISCONNECTED);
20826
+ this.handleDisconnect('negotiation', ReconnectReason.RR_SIGNAL_DISCONNECTED);
20660
20827
  }, this.peerConnectionTimeout);
20661
20828
  const cleanup = () => {
20662
20829
  clearTimeout(negotiationTimeout);
@@ -20675,7 +20842,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20675
20842
  if (e instanceof NegotiationError) {
20676
20843
  this.fullReconnectOnNext = true;
20677
20844
  }
20678
- this.handleDisconnect('negotiation', false, ReconnectReason.REASON_UNKOWN);
20845
+ this.handleDisconnect('negotiation', ReconnectReason.RR_UNKOWN);
20679
20846
  });
20680
20847
  });
20681
20848
  }
@@ -20696,6 +20863,11 @@ class RTCEngine extends eventsExports.EventEmitter {
20696
20863
  }
20697
20864
  }
20698
20865
  }
20866
+ /* @internal */
20867
+ failNext() {
20868
+ // debugging method to fail the next reconnect/resume attempt
20869
+ this.shouldFailNext = true;
20870
+ }
20699
20871
  clearReconnectTimeout() {
20700
20872
  if (this.reconnectTimeout) {
20701
20873
  CriticalTimers.clearTimeout(this.reconnectTimeout);
@@ -20987,37 +21159,47 @@ class Room extends eventsExports.EventEmitter {
20987
21159
  livekitLogger.debug("reconnected to server", {
20988
21160
  region: joinResponse.serverRegion
20989
21161
  });
20990
- this.setAndEmitConnectionState(ConnectionState.Connected);
20991
- this.emit(RoomEvent.Reconnected);
20992
- // rehydrate participants
20993
- if (joinResponse.participant) {
20994
- // with a restart, the sid will have changed, we'll map our understanding to it
20995
- this.localParticipant.sid = joinResponse.participant.sid;
20996
- this.handleParticipantUpdates([joinResponse.participant]);
20997
- }
20998
- this.handleParticipantUpdates(joinResponse.otherParticipants);
20999
- // unpublish & republish tracks
21000
- const localPubs = [];
21001
- this.localParticipant.tracks.forEach(pub => {
21002
- if (pub.track) {
21003
- localPubs.push(pub);
21162
+ try {
21163
+ // rehydrate participants
21164
+ if (joinResponse.participant) {
21165
+ // with a restart, the sid will have changed, we'll map our understanding to it
21166
+ this.localParticipant.sid = joinResponse.participant.sid;
21167
+ this.handleParticipantUpdates([joinResponse.participant]);
21004
21168
  }
21005
- });
21006
- await Promise.all(localPubs.map(async pub => {
21007
- const track = pub.track;
21008
- this.localParticipant.unpublishTrack(track, false);
21009
- if (!track.isMuted) {
21010
- if ((track instanceof LocalAudioTrack || track instanceof LocalVideoTrack) && !track.isUserProvided) {
21011
- // we need to restart the track before publishing, often a full reconnect
21012
- // is necessary because computer had gone to sleep.
21013
- livekitLogger.debug('restarting existing track', {
21169
+ this.handleParticipantUpdates(joinResponse.otherParticipants);
21170
+ // unpublish & republish tracks
21171
+ const localPubs = [];
21172
+ this.localParticipant.tracks.forEach(pub => {
21173
+ if (pub.track) {
21174
+ localPubs.push(pub);
21175
+ }
21176
+ });
21177
+ await Promise.all(localPubs.map(async pub => {
21178
+ const track = pub.track;
21179
+ this.localParticipant.unpublishTrack(track, false);
21180
+ if (!track.isMuted) {
21181
+ if ((track instanceof LocalAudioTrack || track instanceof LocalVideoTrack) && !track.isUserProvided) {
21182
+ // we need to restart the track before publishing, often a full reconnect
21183
+ // is necessary because computer had gone to sleep.
21184
+ livekitLogger.debug('restarting existing track', {
21185
+ track: pub.trackSid
21186
+ });
21187
+ await track.restartTrack();
21188
+ }
21189
+ livekitLogger.debug('publishing new track', {
21014
21190
  track: pub.trackSid
21015
21191
  });
21016
- await track.restartTrack();
21192
+ await this.localParticipant.publishTrack(track, pub.options);
21017
21193
  }
21018
- await this.localParticipant.publishTrack(track, pub.options);
21019
- }
21020
- }));
21194
+ }));
21195
+ } catch (error) {
21196
+ livekitLogger.error('error trying to re-publish tracks after reconnection', {
21197
+ error
21198
+ });
21199
+ } finally {
21200
+ this.setAndEmitConnectionState(ConnectionState.Connected);
21201
+ this.emit(RoomEvent.Reconnected);
21202
+ }
21021
21203
  };
21022
21204
  this.handleParticipantUpdates = participantInfos => {
21023
21205
  // handle changes to participant state, and send events
@@ -21034,14 +21216,16 @@ class Room extends eventsExports.EventEmitter {
21034
21216
  }
21035
21217
  let remoteParticipant = this.participants.get(info.sid);
21036
21218
  const isNewParticipant = !remoteParticipant;
21037
- // create participant if doesn't exist
21038
- remoteParticipant = this.getOrCreateParticipant(info.sid, info);
21039
21219
  // when it's disconnected, send updates
21040
21220
  if (info.state === ParticipantInfo_State.DISCONNECTED) {
21041
21221
  this.handleParticipantDisconnected(info.sid, remoteParticipant);
21042
- } else if (!isNewParticipant) {
21043
- // just update, no events
21044
- remoteParticipant.updateInfo(info);
21222
+ } else {
21223
+ // create participant if doesn't exist
21224
+ remoteParticipant = this.getOrCreateParticipant(info.sid, info);
21225
+ if (!isNewParticipant) {
21226
+ // just update, no events
21227
+ remoteParticipant.updateInfo(info);
21228
+ }
21045
21229
  }
21046
21230
  });
21047
21231
  };
@@ -21133,7 +21317,7 @@ class Room extends eventsExports.EventEmitter {
21133
21317
  this.handleDataPacket = (userPacket, kind) => {
21134
21318
  // find the participant
21135
21319
  const participant = this.participants.get(userPacket.participantSid);
21136
- this.emit(RoomEvent.DataReceived, userPacket.payload, participant, kind);
21320
+ this.emit(RoomEvent.DataReceived, userPacket.payload, participant, kind, userPacket.topic);
21137
21321
  // also emit on the participant
21138
21322
  participant === null || participant === void 0 ? void 0 : participant.emit(ParticipantEvent.DataReceived, userPacket.payload, kind);
21139
21323
  };
@@ -21337,6 +21521,13 @@ class Room extends eventsExports.EventEmitter {
21337
21521
  }
21338
21522
  });
21339
21523
  break;
21524
+ case 'resume-reconnect':
21525
+ this.engine.failNext();
21526
+ await this.engine.client.close();
21527
+ if (this.engine.client.onClose) {
21528
+ this.engine.client.onClose('simulate resume-reconnect');
21529
+ }
21530
+ break;
21340
21531
  case 'force-tcp':
21341
21532
  case 'force-tls':
21342
21533
  req = SimulateScenario.fromPartial({
@@ -21571,7 +21762,7 @@ class Room extends eventsExports.EventEmitter {
21571
21762
  participant.tracks.forEach(publication => {
21572
21763
  participant.unpublishTrack(publication.trackSid, true);
21573
21764
  });
21574
- this.emitWhenConnected(RoomEvent.ParticipantDisconnected, participant);
21765
+ this.emit(RoomEvent.ParticipantDisconnected, participant);
21575
21766
  }
21576
21767
  async acquireAudioContext() {
21577
21768
  var _a, _b;
@@ -21632,7 +21823,7 @@ class Room extends eventsExports.EventEmitter {
21632
21823
  }
21633
21824
  this.emit(RoomEvent.TrackSubscribed, track, publication, participant);
21634
21825
  }).on(ParticipantEvent.TrackUnpublished, publication => {
21635
- this.emitWhenConnected(RoomEvent.TrackUnpublished, publication, participant);
21826
+ this.emit(RoomEvent.TrackUnpublished, publication, participant);
21636
21827
  }).on(ParticipantEvent.TrackUnsubscribed, (track, publication) => {
21637
21828
  this.emit(RoomEvent.TrackUnsubscribed, track, publication, participant);
21638
21829
  }).on(ParticipantEvent.TrackSubscriptionFailed, sid => {