@whereby.com/media 1.10.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1421,6 +1421,10 @@ class VegaConnection extends EventEmitter.EventEmitter {
1421
1421
  var _a;
1422
1422
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
1423
1423
  }
1424
+ isConnected() {
1425
+ var _a, _b;
1426
+ return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN || ((_b = this.socket) === null || _b === void 0 ? void 0 : _b.readyState) === WebSocket.CONNECTING;
1427
+ }
1424
1428
  _onOpen() {
1425
1429
  logger$9.info("Connected");
1426
1430
  this.emit("open");
@@ -5100,6 +5104,9 @@ class VegaRtcManager {
5100
5104
  }), this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, () => {
5101
5105
  if (this._screenVideoTrack)
5102
5106
  this._emitScreenshareStarted();
5107
+ if (!this._vegaConnection.isConnected() && this._reconnect) {
5108
+ this._connect();
5109
+ }
5103
5110
  }));
5104
5111
  this._connect();
5105
5112
  }
@@ -5110,6 +5117,13 @@ class VegaRtcManager {
5110
5117
  });
5111
5118
  }
5112
5119
  _connect() {
5120
+ if (!this._serverSocket.isConnected()) {
5121
+ const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
5122
+ if (!reconnectThresholdInMs)
5123
+ return;
5124
+ if (Date.now() > (this._serverSocket.disconnectTimestamp || 0) + reconnectThresholdInMs)
5125
+ return;
5126
+ }
5113
5127
  const host = this._features.sfuServerOverrideHost || [this._sfuServer.url];
5114
5128
  const searchParams = new URLSearchParams(Object.assign({ clientId: this._selfId, organizationId: this._room.organizationId, roomName: this._room.name, eventClaim: this._room.isClaimed ? this._eventClaim : null, lowBw: "true" }, Object.keys(this._features || {})
5115
5129
  .filter((featureKey) => this._features[featureKey] && /^sfu/.test(featureKey))
@@ -5820,7 +5834,7 @@ class VegaRtcManager {
5820
5834
  if (!videoTrack.effectTrack) {
5821
5835
  this._monitorVideoTrack(videoTrack);
5822
5836
  }
5823
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "video");
5837
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
5824
5838
  if (beforeEffectTrack) {
5825
5839
  this._monitorVideoTrack(beforeEffectTrack);
5826
5840
  }
@@ -5831,7 +5845,7 @@ class VegaRtcManager {
5831
5845
  if (!audioTrack.effectTrack) {
5832
5846
  this._monitorAudioTrack(audioTrack);
5833
5847
  }
5834
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "audio");
5848
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
5835
5849
  if (beforeEffectTrack) {
5836
5850
  this._monitorAudioTrack(beforeEffectTrack);
5837
5851
  }
@@ -5902,7 +5916,9 @@ class VegaRtcManager {
5902
5916
  }
5903
5917
  if (!enable) {
5904
5918
  clearTimeout(this._stopCameraTimeout);
5905
- const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
5919
+ const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended"
5920
+ ? 0
5921
+ : 5000;
5906
5922
  this._stopCameraTimeout = setTimeout(() => {
5907
5923
  localStream.getVideoTracks().forEach((track) => {
5908
5924
  if (track.enabled === false) {
@@ -6454,6 +6470,7 @@ const logger = new Logger();
6454
6470
  class ReconnectManager extends EventEmitter {
6455
6471
  constructor(socket) {
6456
6472
  super();
6473
+ this.reconnectThresholdInMs = 0;
6457
6474
  this._socket = socket;
6458
6475
  this._clients = {};
6459
6476
  this._signalDisconnectTime = undefined;
@@ -6479,6 +6496,7 @@ class ReconnectManager extends EventEmitter {
6479
6496
  _onRoomJoined(payload) {
6480
6497
  var _a, _b;
6481
6498
  return __awaiter(this, void 0, void 0, function* () {
6499
+ this.reconnectThresholdInMs = (payload.disconnectTimeout || 0) * 0.8 || 0;
6482
6500
  if (!((_a = payload.room) === null || _a === void 0 ? void 0 : _a.clients)) {
6483
6501
  this.emit(PROTOCOL_RESPONSES.ROOM_JOINED, payload);
6484
6502
  return;
@@ -6732,6 +6750,7 @@ class ServerSocket {
6732
6750
  }
6733
6751
  });
6734
6752
  this._socket.on("disconnect", () => {
6753
+ this.disconnectTimestamp = Date.now();
6735
6754
  if (this.noopKeepaliveInterval) {
6736
6755
  clearInterval(this.noopKeepaliveInterval);
6737
6756
  this.noopKeepaliveInterval = null;
@@ -6815,6 +6834,10 @@ class ServerSocket {
6815
6834
  var _a;
6816
6835
  return (_a = this._reconnectManager) === null || _a === void 0 ? void 0 : _a.metrics;
6817
6836
  }
6837
+ getReconnectThreshold() {
6838
+ var _a;
6839
+ return (_a = this._reconnectManager) === null || _a === void 0 ? void 0 : _a.reconnectThresholdInMs;
6840
+ }
6818
6841
  }
6819
6842
 
6820
6843
  const defaultSubdomainPattern = /^(?:([^.]+)[.])?((:?[^.]+[.]){1,}[^.]+)$/;
package/dist/index.d.cts CHANGED
@@ -488,6 +488,7 @@ declare class ReconnectManager extends EventEmitter {
488
488
  evaluationFailed: number;
489
489
  roomJoined: number;
490
490
  };
491
+ reconnectThresholdInMs: number;
491
492
  constructor(socket: any);
492
493
  _onRoomJoined(payload: any): Promise<void>;
493
494
  _onClientLeft(payload: any): void;
@@ -516,6 +517,7 @@ declare class ServerSocket {
516
517
  _reconnectManager?: ReconnectManager | null;
517
518
  noopKeepaliveInterval: any;
518
519
  _wasConnectedUsingWebsocket?: boolean;
520
+ disconnectTimestamp: number | undefined;
519
521
  constructor(hostName: string, optionsOverrides?: any, glitchFree?: boolean);
520
522
  setRtcManager(rtcManager?: RtcManager): void;
521
523
  connect(): void;
@@ -525,8 +527,8 @@ declare class ServerSocket {
525
527
  emitIfConnected(eventName: string, data: any): void;
526
528
  getTransport(): any;
527
529
  getManager(): any;
528
- isConnecting(): any;
529
- isConnected(): any;
530
+ isConnecting(): boolean;
531
+ isConnected(): boolean;
530
532
  on(eventName: string, handler: Function): () => void;
531
533
  once(eventName: string, handler: Function): void;
532
534
  off(eventName: string, handler: Function): void;
@@ -537,6 +539,7 @@ declare class ServerSocket {
537
539
  evaluationFailed: number;
538
540
  roomJoined: number;
539
541
  } | undefined;
542
+ getReconnectThreshold(): number | undefined;
540
543
  }
541
544
 
542
545
  declare const maybeTurnOnly: (transportConfig: any, features: {
@@ -692,6 +695,10 @@ interface ClientMetadataReceivedEvent {
692
695
  clientId: string;
693
696
  };
694
697
  }
698
+ interface ClientUnableToJoinEvent {
699
+ displayName: string;
700
+ error: string;
701
+ }
695
702
  interface AudioEnableRequestedEvent {
696
703
  requestedByClientId: string;
697
704
  enable: boolean;
@@ -719,6 +726,7 @@ interface SignalEvents {
719
726
  client_left: ClientLeftEvent;
720
727
  client_kicked: ClientKickedEvent;
721
728
  client_metadata_received: ClientMetadataReceivedEvent;
729
+ client_unable_to_join: ClientUnableToJoinEvent;
722
730
  cloud_recording_started: CloudRecordingStartedEvent;
723
731
  cloud_recording_stopped: void;
724
732
  chat_message: ChatMessage;
@@ -995,6 +1003,7 @@ declare class VegaConnection extends EventEmitter$1 {
995
1003
  _setupSocket(): void;
996
1004
  _tearDown(): void;
997
1005
  close(): void;
1006
+ isConnected(): boolean;
998
1007
  _onOpen(): void;
999
1008
  _onMessage(event: MessageEvent): void;
1000
1009
  _onClose(): void;
@@ -1070,7 +1079,7 @@ declare class VegaRtcManager implements RtcManager {
1070
1079
  _room: any;
1071
1080
  _roomSessionId: any;
1072
1081
  _emitter: any;
1073
- _serverSocket: any;
1082
+ _serverSocket: ServerSocket;
1074
1083
  _webrtcProvider: any;
1075
1084
  _features: any;
1076
1085
  _eventClaim?: any;
@@ -1405,4 +1414,4 @@ declare class RtcStream {
1405
1414
  static getTypeFromId(id: string): string;
1406
1415
  }
1407
1416
 
1408
- export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
1417
+ export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type ClientUnableToJoinEvent, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
package/dist/index.d.mts CHANGED
@@ -488,6 +488,7 @@ declare class ReconnectManager extends EventEmitter {
488
488
  evaluationFailed: number;
489
489
  roomJoined: number;
490
490
  };
491
+ reconnectThresholdInMs: number;
491
492
  constructor(socket: any);
492
493
  _onRoomJoined(payload: any): Promise<void>;
493
494
  _onClientLeft(payload: any): void;
@@ -516,6 +517,7 @@ declare class ServerSocket {
516
517
  _reconnectManager?: ReconnectManager | null;
517
518
  noopKeepaliveInterval: any;
518
519
  _wasConnectedUsingWebsocket?: boolean;
520
+ disconnectTimestamp: number | undefined;
519
521
  constructor(hostName: string, optionsOverrides?: any, glitchFree?: boolean);
520
522
  setRtcManager(rtcManager?: RtcManager): void;
521
523
  connect(): void;
@@ -525,8 +527,8 @@ declare class ServerSocket {
525
527
  emitIfConnected(eventName: string, data: any): void;
526
528
  getTransport(): any;
527
529
  getManager(): any;
528
- isConnecting(): any;
529
- isConnected(): any;
530
+ isConnecting(): boolean;
531
+ isConnected(): boolean;
530
532
  on(eventName: string, handler: Function): () => void;
531
533
  once(eventName: string, handler: Function): void;
532
534
  off(eventName: string, handler: Function): void;
@@ -537,6 +539,7 @@ declare class ServerSocket {
537
539
  evaluationFailed: number;
538
540
  roomJoined: number;
539
541
  } | undefined;
542
+ getReconnectThreshold(): number | undefined;
540
543
  }
541
544
 
542
545
  declare const maybeTurnOnly: (transportConfig: any, features: {
@@ -692,6 +695,10 @@ interface ClientMetadataReceivedEvent {
692
695
  clientId: string;
693
696
  };
694
697
  }
698
+ interface ClientUnableToJoinEvent {
699
+ displayName: string;
700
+ error: string;
701
+ }
695
702
  interface AudioEnableRequestedEvent {
696
703
  requestedByClientId: string;
697
704
  enable: boolean;
@@ -719,6 +726,7 @@ interface SignalEvents {
719
726
  client_left: ClientLeftEvent;
720
727
  client_kicked: ClientKickedEvent;
721
728
  client_metadata_received: ClientMetadataReceivedEvent;
729
+ client_unable_to_join: ClientUnableToJoinEvent;
722
730
  cloud_recording_started: CloudRecordingStartedEvent;
723
731
  cloud_recording_stopped: void;
724
732
  chat_message: ChatMessage;
@@ -995,6 +1003,7 @@ declare class VegaConnection extends EventEmitter$1 {
995
1003
  _setupSocket(): void;
996
1004
  _tearDown(): void;
997
1005
  close(): void;
1006
+ isConnected(): boolean;
998
1007
  _onOpen(): void;
999
1008
  _onMessage(event: MessageEvent): void;
1000
1009
  _onClose(): void;
@@ -1070,7 +1079,7 @@ declare class VegaRtcManager implements RtcManager {
1070
1079
  _room: any;
1071
1080
  _roomSessionId: any;
1072
1081
  _emitter: any;
1073
- _serverSocket: any;
1082
+ _serverSocket: ServerSocket;
1074
1083
  _webrtcProvider: any;
1075
1084
  _features: any;
1076
1085
  _eventClaim?: any;
@@ -1405,4 +1414,4 @@ declare class RtcStream {
1405
1414
  static getTypeFromId(id: string): string;
1406
1415
  }
1407
1416
 
1408
- export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
1417
+ export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type ClientUnableToJoinEvent, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
package/dist/index.d.ts CHANGED
@@ -488,6 +488,7 @@ declare class ReconnectManager extends EventEmitter {
488
488
  evaluationFailed: number;
489
489
  roomJoined: number;
490
490
  };
491
+ reconnectThresholdInMs: number;
491
492
  constructor(socket: any);
492
493
  _onRoomJoined(payload: any): Promise<void>;
493
494
  _onClientLeft(payload: any): void;
@@ -516,6 +517,7 @@ declare class ServerSocket {
516
517
  _reconnectManager?: ReconnectManager | null;
517
518
  noopKeepaliveInterval: any;
518
519
  _wasConnectedUsingWebsocket?: boolean;
520
+ disconnectTimestamp: number | undefined;
519
521
  constructor(hostName: string, optionsOverrides?: any, glitchFree?: boolean);
520
522
  setRtcManager(rtcManager?: RtcManager): void;
521
523
  connect(): void;
@@ -525,8 +527,8 @@ declare class ServerSocket {
525
527
  emitIfConnected(eventName: string, data: any): void;
526
528
  getTransport(): any;
527
529
  getManager(): any;
528
- isConnecting(): any;
529
- isConnected(): any;
530
+ isConnecting(): boolean;
531
+ isConnected(): boolean;
530
532
  on(eventName: string, handler: Function): () => void;
531
533
  once(eventName: string, handler: Function): void;
532
534
  off(eventName: string, handler: Function): void;
@@ -537,6 +539,7 @@ declare class ServerSocket {
537
539
  evaluationFailed: number;
538
540
  roomJoined: number;
539
541
  } | undefined;
542
+ getReconnectThreshold(): number | undefined;
540
543
  }
541
544
 
542
545
  declare const maybeTurnOnly: (transportConfig: any, features: {
@@ -692,6 +695,10 @@ interface ClientMetadataReceivedEvent {
692
695
  clientId: string;
693
696
  };
694
697
  }
698
+ interface ClientUnableToJoinEvent {
699
+ displayName: string;
700
+ error: string;
701
+ }
695
702
  interface AudioEnableRequestedEvent {
696
703
  requestedByClientId: string;
697
704
  enable: boolean;
@@ -719,6 +726,7 @@ interface SignalEvents {
719
726
  client_left: ClientLeftEvent;
720
727
  client_kicked: ClientKickedEvent;
721
728
  client_metadata_received: ClientMetadataReceivedEvent;
729
+ client_unable_to_join: ClientUnableToJoinEvent;
722
730
  cloud_recording_started: CloudRecordingStartedEvent;
723
731
  cloud_recording_stopped: void;
724
732
  chat_message: ChatMessage;
@@ -995,6 +1003,7 @@ declare class VegaConnection extends EventEmitter$1 {
995
1003
  _setupSocket(): void;
996
1004
  _tearDown(): void;
997
1005
  close(): void;
1006
+ isConnected(): boolean;
998
1007
  _onOpen(): void;
999
1008
  _onMessage(event: MessageEvent): void;
1000
1009
  _onClose(): void;
@@ -1070,7 +1079,7 @@ declare class VegaRtcManager implements RtcManager {
1070
1079
  _room: any;
1071
1080
  _roomSessionId: any;
1072
1081
  _emitter: any;
1073
- _serverSocket: any;
1082
+ _serverSocket: ServerSocket;
1074
1083
  _webrtcProvider: any;
1075
1084
  _features: any;
1076
1085
  _eventClaim?: any;
@@ -1405,4 +1414,4 @@ declare class RtcStream {
1405
1414
  static getTypeFromId(id: string): string;
1406
1415
  }
1407
1416
 
1408
- export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
1417
+ export { type AddSpotlightRequest, type AudioEnableRequest, type AudioEnableRequestedEvent, type AudioEnabledEvent, BandwidthTester, type ChatMessage, type ClientKickedEvent, type ClientLeftEvent, type ClientMetadataPayload, type ClientMetadataReceivedEvent, type ClientRole, type ClientUnableToJoinEvent, type CloudRecordingStartedEvent, type Credentials, type CustomMediaStreamTrack, EVENTS, type GetConstraintsOptions, type GetDeviceDataResult, type GetMediaConstraintsOptions, type GetStreamOptions, type GetStreamResult, type GetUpdatedDevicesResult, type IdentifyDeviceRequest, type JoinRoomRequest, KNOCK_MESSAGES, KalmanFilter, type KnockAcceptedEvent, type KnockRejectedEvent, type KnockRoomRequest, type KnockerLeftEvent, type LiveTranscriptionStartedEvent, type LiveTranscriptionStoppedEvent, Logger, MAXIMUM_TURN_BANDWIDTH, MAXIMUM_TURN_BANDWIDTH_UNLIMITED, MEDIA_JITTER_BUFFER_TARGET, type NewClientEvent, NoDevicesError, P2pRtcManager, PROTOCOL_ERRORS, PROTOCOL_EVENTS, PROTOCOL_REQUESTS, PROTOCOL_RESPONSES, RELAY_MESSAGES, ReconnectManager, type RemoveSpotlightRequest, type RoleName, type RoomJoinedEvent, type RoomKnockedEvent, type RoomLockedEvent, type RoomSessionEndedEvent, type RtcClientConnectionStatusChangedPayload, RtcEventNames, type RtcEvents, type RtcLocalStreamTrackAddedPayload, type RtcLocalStreamTrackRemovedPayload, type RtcManager, type RtcManagerCreatedPayload, RtcManagerDispatcher, RtcStream, type RtcStreamAddedPayload, STREAM_TYPES, type ScreenshareStartedEvent, type ScreenshareStoppedEvent, type SendClientMetadataRequest, ServerSocket, Session, SfuV2Parser, type SignalClient, type SignalEvents, type SignalKnocker, type SignalRequests, type SocketConf, type SocketManager, type Spotlight, type SpotlightAddedEvent, type SpotlightRemovedEvent, type StatsMonitorOptions, type StatsMonitorState, TYPES, VegaConnection, VegaMediaQualityMonitor, VegaRtcManager, type VideoEnabledEvent, addAbsCaptureTimeExtMap, addExtMap, assert, buildDeviceList, calculateStd, captureAudioSsrcMetrics, captureCandidatePairInfoMetrics, captureCommonSsrcMetrics, captureSsrcInfo, captureVideoSsrcMetrics, changeMediaDirection, compareLocalDevices, createACFCalculator, createMicAnalyser, createWorker, deprioritizeH264, detectMicrophoneNotWorking, enumerate, filterMidExtension, filterMsidSemantic, fromLocation, generateByteString, getConstraints, getCurrentPeerConnections, getDeviceData, getDisplayMedia, getHandler, getIssuesAndMetrics, getMediaConstraints, getMediaSettings, getOptimalBitrate, getPeerConnectionIndex, getStats, getStream, getStream2, getUpdatedDevices, getUpdatedStats, getUserMedia, hasGetDisplayMedia, ipRegex, isMobile, isRelayed, maybeRejectNoH264, maybeTurnOnly, modifyMediaCapabilities, removePeerConnection, replaceSSRCs, replaceTracksInStream, _default as rtcManagerEvents, rtcStats, setClientProvider, setCodecPreferenceSDP, setPeerConnectionsForTests, setVideoBandwidthUsingSetParameters, standardDeviation, startPerformanceMonitor, stopStreamTracks, subscribeIssues, subscribeStats, variance };
package/dist/index.mjs CHANGED
@@ -1400,6 +1400,10 @@ class VegaConnection extends EventEmitter {
1400
1400
  var _a;
1401
1401
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
1402
1402
  }
1403
+ isConnected() {
1404
+ var _a, _b;
1405
+ return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN || ((_b = this.socket) === null || _b === void 0 ? void 0 : _b.readyState) === WebSocket.CONNECTING;
1406
+ }
1403
1407
  _onOpen() {
1404
1408
  logger$9.info("Connected");
1405
1409
  this.emit("open");
@@ -5079,6 +5083,9 @@ class VegaRtcManager {
5079
5083
  }), this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, () => {
5080
5084
  if (this._screenVideoTrack)
5081
5085
  this._emitScreenshareStarted();
5086
+ if (!this._vegaConnection.isConnected() && this._reconnect) {
5087
+ this._connect();
5088
+ }
5082
5089
  }));
5083
5090
  this._connect();
5084
5091
  }
@@ -5089,6 +5096,13 @@ class VegaRtcManager {
5089
5096
  });
5090
5097
  }
5091
5098
  _connect() {
5099
+ if (!this._serverSocket.isConnected()) {
5100
+ const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
5101
+ if (!reconnectThresholdInMs)
5102
+ return;
5103
+ if (Date.now() > (this._serverSocket.disconnectTimestamp || 0) + reconnectThresholdInMs)
5104
+ return;
5105
+ }
5092
5106
  const host = this._features.sfuServerOverrideHost || [this._sfuServer.url];
5093
5107
  const searchParams = new URLSearchParams(Object.assign({ clientId: this._selfId, organizationId: this._room.organizationId, roomName: this._room.name, eventClaim: this._room.isClaimed ? this._eventClaim : null, lowBw: "true" }, Object.keys(this._features || {})
5094
5108
  .filter((featureKey) => this._features[featureKey] && /^sfu/.test(featureKey))
@@ -5799,7 +5813,7 @@ class VegaRtcManager {
5799
5813
  if (!videoTrack.effectTrack) {
5800
5814
  this._monitorVideoTrack(videoTrack);
5801
5815
  }
5802
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "video");
5816
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
5803
5817
  if (beforeEffectTrack) {
5804
5818
  this._monitorVideoTrack(beforeEffectTrack);
5805
5819
  }
@@ -5810,7 +5824,7 @@ class VegaRtcManager {
5810
5824
  if (!audioTrack.effectTrack) {
5811
5825
  this._monitorAudioTrack(audioTrack);
5812
5826
  }
5813
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "audio");
5827
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
5814
5828
  if (beforeEffectTrack) {
5815
5829
  this._monitorAudioTrack(beforeEffectTrack);
5816
5830
  }
@@ -5881,7 +5895,9 @@ class VegaRtcManager {
5881
5895
  }
5882
5896
  if (!enable) {
5883
5897
  clearTimeout(this._stopCameraTimeout);
5884
- const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
5898
+ const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended"
5899
+ ? 0
5900
+ : 5000;
5885
5901
  this._stopCameraTimeout = setTimeout(() => {
5886
5902
  localStream.getVideoTracks().forEach((track) => {
5887
5903
  if (track.enabled === false) {
@@ -6433,6 +6449,7 @@ const logger = new Logger();
6433
6449
  class ReconnectManager extends EventEmitter$1 {
6434
6450
  constructor(socket) {
6435
6451
  super();
6452
+ this.reconnectThresholdInMs = 0;
6436
6453
  this._socket = socket;
6437
6454
  this._clients = {};
6438
6455
  this._signalDisconnectTime = undefined;
@@ -6458,6 +6475,7 @@ class ReconnectManager extends EventEmitter$1 {
6458
6475
  _onRoomJoined(payload) {
6459
6476
  var _a, _b;
6460
6477
  return __awaiter(this, void 0, void 0, function* () {
6478
+ this.reconnectThresholdInMs = (payload.disconnectTimeout || 0) * 0.8 || 0;
6461
6479
  if (!((_a = payload.room) === null || _a === void 0 ? void 0 : _a.clients)) {
6462
6480
  this.emit(PROTOCOL_RESPONSES.ROOM_JOINED, payload);
6463
6481
  return;
@@ -6711,6 +6729,7 @@ class ServerSocket {
6711
6729
  }
6712
6730
  });
6713
6731
  this._socket.on("disconnect", () => {
6732
+ this.disconnectTimestamp = Date.now();
6714
6733
  if (this.noopKeepaliveInterval) {
6715
6734
  clearInterval(this.noopKeepaliveInterval);
6716
6735
  this.noopKeepaliveInterval = null;
@@ -6794,6 +6813,10 @@ class ServerSocket {
6794
6813
  var _a;
6795
6814
  return (_a = this._reconnectManager) === null || _a === void 0 ? void 0 : _a.metrics;
6796
6815
  }
6816
+ getReconnectThreshold() {
6817
+ var _a;
6818
+ return (_a = this._reconnectManager) === null || _a === void 0 ? void 0 : _a.reconnectThresholdInMs;
6819
+ }
6797
6820
  }
6798
6821
 
6799
6822
  const defaultSubdomainPattern = /^(?:([^.]+)[.])?((:?[^.]+[.]){1,}[^.]+)$/;
@@ -1400,6 +1400,10 @@ class VegaConnection extends EventEmitter {
1400
1400
  var _a;
1401
1401
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
1402
1402
  }
1403
+ isConnected() {
1404
+ var _a, _b;
1405
+ return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN || ((_b = this.socket) === null || _b === void 0 ? void 0 : _b.readyState) === WebSocket.CONNECTING;
1406
+ }
1403
1407
  _onOpen() {
1404
1408
  logger$9.info("Connected");
1405
1409
  this.emit("open");
@@ -5079,6 +5083,9 @@ class VegaRtcManager {
5079
5083
  }), this._serverSocket.on(PROTOCOL_RESPONSES.ROOM_JOINED, () => {
5080
5084
  if (this._screenVideoTrack)
5081
5085
  this._emitScreenshareStarted();
5086
+ if (!this._vegaConnection.isConnected() && this._reconnect) {
5087
+ this._connect();
5088
+ }
5082
5089
  }));
5083
5090
  this._connect();
5084
5091
  }
@@ -5089,6 +5096,13 @@ class VegaRtcManager {
5089
5096
  });
5090
5097
  }
5091
5098
  _connect() {
5099
+ if (!this._serverSocket.isConnected()) {
5100
+ const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
5101
+ if (!reconnectThresholdInMs)
5102
+ return;
5103
+ if (Date.now() > (this._serverSocket.disconnectTimestamp || 0) + reconnectThresholdInMs)
5104
+ return;
5105
+ }
5092
5106
  const host = this._features.sfuServerOverrideHost || [this._sfuServer.url];
5093
5107
  const searchParams = new URLSearchParams(Object.assign({ clientId: this._selfId, organizationId: this._room.organizationId, roomName: this._room.name, eventClaim: this._room.isClaimed ? this._eventClaim : null, lowBw: "true" }, Object.keys(this._features || {})
5094
5108
  .filter((featureKey) => this._features[featureKey] && /^sfu/.test(featureKey))
@@ -5799,7 +5813,7 @@ class VegaRtcManager {
5799
5813
  if (!videoTrack.effectTrack) {
5800
5814
  this._monitorVideoTrack(videoTrack);
5801
5815
  }
5802
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "video");
5816
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "video");
5803
5817
  if (beforeEffectTrack) {
5804
5818
  this._monitorVideoTrack(beforeEffectTrack);
5805
5819
  }
@@ -5810,7 +5824,7 @@ class VegaRtcManager {
5810
5824
  if (!audioTrack.effectTrack) {
5811
5825
  this._monitorAudioTrack(audioTrack);
5812
5826
  }
5813
- const beforeEffectTrack = beforeEffectTracks.find(t => t.kind === "audio");
5827
+ const beforeEffectTrack = beforeEffectTracks.find((t) => t.kind === "audio");
5814
5828
  if (beforeEffectTrack) {
5815
5829
  this._monitorAudioTrack(beforeEffectTrack);
5816
5830
  }
@@ -5881,7 +5895,9 @@ class VegaRtcManager {
5881
5895
  }
5882
5896
  if (!enable) {
5883
5897
  clearTimeout(this._stopCameraTimeout);
5884
- const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended" ? 0 : 5000;
5898
+ const stopCameraDelay = ((_a = localStream.getVideoTracks().find((t) => !t.enabled)) === null || _a === void 0 ? void 0 : _a.readyState) === "ended"
5899
+ ? 0
5900
+ : 5000;
5885
5901
  this._stopCameraTimeout = setTimeout(() => {
5886
5902
  localStream.getVideoTracks().forEach((track) => {
5887
5903
  if (track.enabled === false) {
@@ -6433,6 +6449,7 @@ const logger = new Logger();
6433
6449
  class ReconnectManager extends EventEmitter$1 {
6434
6450
  constructor(socket) {
6435
6451
  super();
6452
+ this.reconnectThresholdInMs = 0;
6436
6453
  this._socket = socket;
6437
6454
  this._clients = {};
6438
6455
  this._signalDisconnectTime = undefined;
@@ -6458,6 +6475,7 @@ class ReconnectManager extends EventEmitter$1 {
6458
6475
  _onRoomJoined(payload) {
6459
6476
  var _a, _b;
6460
6477
  return __awaiter(this, void 0, void 0, function* () {
6478
+ this.reconnectThresholdInMs = (payload.disconnectTimeout || 0) * 0.8 || 0;
6461
6479
  if (!((_a = payload.room) === null || _a === void 0 ? void 0 : _a.clients)) {
6462
6480
  this.emit(PROTOCOL_RESPONSES.ROOM_JOINED, payload);
6463
6481
  return;
@@ -6711,6 +6729,7 @@ class ServerSocket {
6711
6729
  }
6712
6730
  });
6713
6731
  this._socket.on("disconnect", () => {
6732
+ this.disconnectTimestamp = Date.now();
6714
6733
  if (this.noopKeepaliveInterval) {
6715
6734
  clearInterval(this.noopKeepaliveInterval);
6716
6735
  this.noopKeepaliveInterval = null;
@@ -6794,6 +6813,10 @@ class ServerSocket {
6794
6813
  var _a;
6795
6814
  return (_a = this._reconnectManager) === null || _a === void 0 ? void 0 : _a.metrics;
6796
6815
  }
6816
+ getReconnectThreshold() {
6817
+ var _a;
6818
+ return (_a = this._reconnectManager) === null || _a === void 0 ? void 0 : _a.reconnectThresholdInMs;
6819
+ }
6797
6820
  }
6798
6821
 
6799
6822
  const defaultSubdomainPattern = /^(?:([^.]+)[.])?((:?[^.]+[.]){1,}[^.]+)$/;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "1.10.1",
4
+ "version": "1.11.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {