@whereby.com/media 2.6.10 → 2.7.1
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 +28 -20
- package/dist/index.d.cts +6 -4
- package/dist/index.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +28 -20
- package/dist/legacy-esm.js +28 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1566,6 +1566,7 @@ var _a$6;
|
|
|
1566
1566
|
const adapter$6 = (_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6 : adapterRaw;
|
|
1567
1567
|
const DEFAULT_SOCKET_PATH = "/protocol/socket.io/v4";
|
|
1568
1568
|
const NOOP_KEEPALIVE_INTERVAL = 2000;
|
|
1569
|
+
const DISCONNECT_DURATION_LIMIT_MS = 60000;
|
|
1569
1570
|
class ServerSocket {
|
|
1570
1571
|
constructor(hostName, optionsOverrides, glitchFree = false, disconnectDurationLimitOn = false) {
|
|
1571
1572
|
this._wasConnectedUsingWebsocket = false;
|
|
@@ -1573,21 +1574,22 @@ class ServerSocket {
|
|
|
1573
1574
|
this.disconnectDurationLimitExceeded = false;
|
|
1574
1575
|
this._reconnectManager = null;
|
|
1575
1576
|
this._socket = socket_ioClient.io(hostName, Object.assign({ path: DEFAULT_SOCKET_PATH, randomizationFactor: 0.5, reconnectionDelay: 250, reconnectionDelayMax: 5000, timeout: 5000, transports: ["websocket"], withCredentials: true }, optionsOverrides));
|
|
1577
|
+
this._disconnectDurationLimitEnabled = false;
|
|
1576
1578
|
this.joinRoomFinished = false;
|
|
1577
1579
|
this._socket.io.on("reconnect", () => {
|
|
1578
|
-
if (this._disconnectDurationLimitOn &&
|
|
1580
|
+
if (this._disconnectDurationLimitOn &&
|
|
1581
|
+
this._didExceedDisconnectDurationLimit(this._disconnectDurationLimitLatestTimestamp)) {
|
|
1579
1582
|
this._socket.close();
|
|
1580
1583
|
this.disconnectDurationLimitExceeded = true;
|
|
1581
|
-
return;
|
|
1582
1584
|
}
|
|
1583
1585
|
this._socket.sendBuffer = [];
|
|
1584
1586
|
});
|
|
1585
1587
|
this._socket.io.on("reconnect_attempt", () => {
|
|
1586
1588
|
var _a;
|
|
1587
|
-
if (this._disconnectDurationLimitOn &&
|
|
1589
|
+
if (this._disconnectDurationLimitOn &&
|
|
1590
|
+
this._didExceedDisconnectDurationLimit(this._disconnectDurationLimitLatestTimestamp)) {
|
|
1588
1591
|
this._socket.close();
|
|
1589
1592
|
this.disconnectDurationLimitExceeded = true;
|
|
1590
|
-
return;
|
|
1591
1593
|
}
|
|
1592
1594
|
if (this._wasConnectedUsingWebsocket) {
|
|
1593
1595
|
this._socket.io.opts.transports = ["websocket"];
|
|
@@ -1611,25 +1613,30 @@ class ServerSocket {
|
|
|
1611
1613
|
const transport = this.getTransport();
|
|
1612
1614
|
if (transport === "websocket") {
|
|
1613
1615
|
this._wasConnectedUsingWebsocket = true;
|
|
1614
|
-
if (!this.noopKeepaliveInterval)
|
|
1616
|
+
if (!this.noopKeepaliveInterval) {
|
|
1617
|
+
let disconnectDurationLimitTimestampCandidate = Date.now();
|
|
1615
1618
|
this.noopKeepaliveInterval = setInterval(() => {
|
|
1616
1619
|
try {
|
|
1617
1620
|
if (this._socket.connected) {
|
|
1618
|
-
if (this._disconnectDurationLimitOn
|
|
1619
|
-
this.
|
|
1621
|
+
if (this._disconnectDurationLimitOn &&
|
|
1622
|
+
!this._didExceedDisconnectDurationLimit(disconnectDurationLimitTimestampCandidate)) {
|
|
1623
|
+
this._disconnectDurationLimitLatestTimestamp =
|
|
1624
|
+
disconnectDurationLimitTimestampCandidate;
|
|
1625
|
+
disconnectDurationLimitTimestampCandidate = Date.now();
|
|
1620
1626
|
}
|
|
1621
1627
|
this._socket.io.engine.sendPacket("noop");
|
|
1622
1628
|
}
|
|
1623
1629
|
}
|
|
1624
1630
|
catch (ex) { }
|
|
1625
1631
|
}, NOOP_KEEPALIVE_INTERVAL);
|
|
1632
|
+
}
|
|
1626
1633
|
}
|
|
1627
1634
|
});
|
|
1628
1635
|
this._socket.on("disconnect", () => {
|
|
1629
|
-
if (this._disconnectDurationLimitOn &&
|
|
1636
|
+
if (this._disconnectDurationLimitOn &&
|
|
1637
|
+
this._didExceedDisconnectDurationLimit(this._disconnectDurationLimitLatestTimestamp)) {
|
|
1630
1638
|
this._socket.close();
|
|
1631
1639
|
this.disconnectDurationLimitExceeded = true;
|
|
1632
|
-
return;
|
|
1633
1640
|
}
|
|
1634
1641
|
this.joinRoomFinished = false;
|
|
1635
1642
|
this.disconnectTimestamp = Date.now();
|
|
@@ -1639,20 +1646,18 @@ class ServerSocket {
|
|
|
1639
1646
|
}
|
|
1640
1647
|
});
|
|
1641
1648
|
}
|
|
1642
|
-
_didExceedDisconnectDurationLimit() {
|
|
1643
|
-
if (!this._disconnectDurationLimitOn)
|
|
1644
|
-
return false;
|
|
1645
|
-
if (this._disconnectDurationLimitInMs && this._noopKeepaliveTimestamp) {
|
|
1646
|
-
const disconnectedDuration = Date.now() - this._noopKeepaliveTimestamp;
|
|
1647
|
-
if (disconnectedDuration > this._disconnectDurationLimitInMs) {
|
|
1648
|
-
return true;
|
|
1649
|
-
}
|
|
1649
|
+
_didExceedDisconnectDurationLimit(timestamp) {
|
|
1650
|
+
if (!timestamp || !this._disconnectDurationLimitOn || !this._disconnectDurationLimitEnabled)
|
|
1650
1651
|
return false;
|
|
1652
|
+
const disconnectedDuration = Date.now() - timestamp;
|
|
1653
|
+
if (disconnectedDuration > DISCONNECT_DURATION_LIMIT_MS) {
|
|
1654
|
+
return true;
|
|
1651
1655
|
}
|
|
1656
|
+
return false;
|
|
1652
1657
|
}
|
|
1653
|
-
|
|
1658
|
+
enableDisconnectDurationLimit() {
|
|
1654
1659
|
if (this._disconnectDurationLimitOn) {
|
|
1655
|
-
this.
|
|
1660
|
+
this._disconnectDurationLimitEnabled = true;
|
|
1656
1661
|
}
|
|
1657
1662
|
}
|
|
1658
1663
|
setRtcManager(rtcManager) {
|
|
@@ -2797,6 +2802,7 @@ class P2pRtcManager {
|
|
|
2797
2802
|
this._localStreamDeregisterFunction();
|
|
2798
2803
|
this._localStreamDeregisterFunction = null;
|
|
2799
2804
|
}
|
|
2805
|
+
this.rtcStatsDisconnect();
|
|
2800
2806
|
}
|
|
2801
2807
|
setupSocketListeners() {
|
|
2802
2808
|
this._socketListenerDeregisterFunctions = [
|
|
@@ -2899,6 +2905,7 @@ class P2pRtcManager {
|
|
|
2899
2905
|
}
|
|
2900
2906
|
}
|
|
2901
2907
|
rtcStatsDisconnect() {
|
|
2908
|
+
clearTimeout(this._rtcStatsDisconnectTimeout);
|
|
2902
2909
|
rtcStats.server.close();
|
|
2903
2910
|
}
|
|
2904
2911
|
rtcStatsReconnect() {
|
|
@@ -3624,7 +3631,7 @@ class P2pRtcManager {
|
|
|
3624
3631
|
this._changeBandwidthForAllClients(false);
|
|
3625
3632
|
const numPeers = this.numberOfPeerconnections();
|
|
3626
3633
|
if (numPeers === 0) {
|
|
3627
|
-
setTimeout(() => {
|
|
3634
|
+
this._rtcStatsDisconnectTimeout = setTimeout(() => {
|
|
3628
3635
|
const numPeers = this.numberOfPeerconnections();
|
|
3629
3636
|
if (numPeers === 0) {
|
|
3630
3637
|
this.rtcStatsDisconnect();
|
|
@@ -5723,6 +5730,7 @@ class VegaRtcManager {
|
|
|
5723
5730
|
this._screenAudioTrack = null;
|
|
5724
5731
|
this._streamIdToVideoConsumerId.clear();
|
|
5725
5732
|
this._mediasoupDeviceInitializedAsync = Promise.resolve(null);
|
|
5733
|
+
this._qualityMonitor.close();
|
|
5726
5734
|
}
|
|
5727
5735
|
sendAudioMutedStats(muted) {
|
|
5728
5736
|
rtcStats.sendEvent("audio_muted", { muted });
|
package/dist/index.d.cts
CHANGED
|
@@ -708,16 +708,17 @@ declare class ServerSocket {
|
|
|
708
708
|
_socket: any;
|
|
709
709
|
_reconnectManager?: ReconnectManager | null;
|
|
710
710
|
noopKeepaliveInterval: any;
|
|
711
|
-
_noopKeepaliveTimestamp: number | undefined;
|
|
712
711
|
_wasConnectedUsingWebsocket?: boolean;
|
|
713
712
|
disconnectTimestamp: number | undefined;
|
|
714
713
|
disconnectDurationLimitExceeded: boolean;
|
|
715
714
|
joinRoomFinished: boolean;
|
|
716
715
|
_disconnectDurationLimitOn: boolean;
|
|
716
|
+
_disconnectDurationLimitEnabled: boolean;
|
|
717
717
|
_disconnectDurationLimitInMs: number | undefined;
|
|
718
|
+
_disconnectDurationLimitLatestTimestamp: number | undefined;
|
|
718
719
|
constructor(hostName: string, optionsOverrides?: any, glitchFree?: boolean, disconnectDurationLimitOn?: boolean);
|
|
719
|
-
_didExceedDisconnectDurationLimit(
|
|
720
|
-
|
|
720
|
+
_didExceedDisconnectDurationLimit(timestamp: number | undefined): boolean;
|
|
721
|
+
enableDisconnectDurationLimit(): void;
|
|
721
722
|
setRtcManager(rtcManager?: RtcManager): void;
|
|
722
723
|
connect(): void;
|
|
723
724
|
disconnect(): void;
|
|
@@ -1226,6 +1227,7 @@ declare class P2pRtcManager implements RtcManager {
|
|
|
1226
1227
|
_closed: boolean;
|
|
1227
1228
|
skipEmittingServerMessageCount: number;
|
|
1228
1229
|
analytics: P2PAnalytics;
|
|
1230
|
+
_rtcStatsDisconnectTimeout?: ReturnType<typeof setTimeout>;
|
|
1229
1231
|
constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }: {
|
|
1230
1232
|
selfId: any;
|
|
1231
1233
|
room: any;
|
|
@@ -1595,7 +1597,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1595
1597
|
_socketListenerDeregisterFunctions: any;
|
|
1596
1598
|
_reconnect: any;
|
|
1597
1599
|
_reconnectTimeOut: any;
|
|
1598
|
-
_qualityMonitor:
|
|
1600
|
+
_qualityMonitor: VegaMediaQualityMonitor;
|
|
1599
1601
|
_fetchMediaServersTimer: any;
|
|
1600
1602
|
_iceServers: any;
|
|
1601
1603
|
_turnServers: any;
|
package/dist/index.d.mts
CHANGED
|
@@ -708,16 +708,17 @@ declare class ServerSocket {
|
|
|
708
708
|
_socket: any;
|
|
709
709
|
_reconnectManager?: ReconnectManager | null;
|
|
710
710
|
noopKeepaliveInterval: any;
|
|
711
|
-
_noopKeepaliveTimestamp: number | undefined;
|
|
712
711
|
_wasConnectedUsingWebsocket?: boolean;
|
|
713
712
|
disconnectTimestamp: number | undefined;
|
|
714
713
|
disconnectDurationLimitExceeded: boolean;
|
|
715
714
|
joinRoomFinished: boolean;
|
|
716
715
|
_disconnectDurationLimitOn: boolean;
|
|
716
|
+
_disconnectDurationLimitEnabled: boolean;
|
|
717
717
|
_disconnectDurationLimitInMs: number | undefined;
|
|
718
|
+
_disconnectDurationLimitLatestTimestamp: number | undefined;
|
|
718
719
|
constructor(hostName: string, optionsOverrides?: any, glitchFree?: boolean, disconnectDurationLimitOn?: boolean);
|
|
719
|
-
_didExceedDisconnectDurationLimit(
|
|
720
|
-
|
|
720
|
+
_didExceedDisconnectDurationLimit(timestamp: number | undefined): boolean;
|
|
721
|
+
enableDisconnectDurationLimit(): void;
|
|
721
722
|
setRtcManager(rtcManager?: RtcManager): void;
|
|
722
723
|
connect(): void;
|
|
723
724
|
disconnect(): void;
|
|
@@ -1226,6 +1227,7 @@ declare class P2pRtcManager implements RtcManager {
|
|
|
1226
1227
|
_closed: boolean;
|
|
1227
1228
|
skipEmittingServerMessageCount: number;
|
|
1228
1229
|
analytics: P2PAnalytics;
|
|
1230
|
+
_rtcStatsDisconnectTimeout?: ReturnType<typeof setTimeout>;
|
|
1229
1231
|
constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }: {
|
|
1230
1232
|
selfId: any;
|
|
1231
1233
|
room: any;
|
|
@@ -1595,7 +1597,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1595
1597
|
_socketListenerDeregisterFunctions: any;
|
|
1596
1598
|
_reconnect: any;
|
|
1597
1599
|
_reconnectTimeOut: any;
|
|
1598
|
-
_qualityMonitor:
|
|
1600
|
+
_qualityMonitor: VegaMediaQualityMonitor;
|
|
1599
1601
|
_fetchMediaServersTimer: any;
|
|
1600
1602
|
_iceServers: any;
|
|
1601
1603
|
_turnServers: any;
|
package/dist/index.d.ts
CHANGED
|
@@ -708,16 +708,17 @@ declare class ServerSocket {
|
|
|
708
708
|
_socket: any;
|
|
709
709
|
_reconnectManager?: ReconnectManager | null;
|
|
710
710
|
noopKeepaliveInterval: any;
|
|
711
|
-
_noopKeepaliveTimestamp: number | undefined;
|
|
712
711
|
_wasConnectedUsingWebsocket?: boolean;
|
|
713
712
|
disconnectTimestamp: number | undefined;
|
|
714
713
|
disconnectDurationLimitExceeded: boolean;
|
|
715
714
|
joinRoomFinished: boolean;
|
|
716
715
|
_disconnectDurationLimitOn: boolean;
|
|
716
|
+
_disconnectDurationLimitEnabled: boolean;
|
|
717
717
|
_disconnectDurationLimitInMs: number | undefined;
|
|
718
|
+
_disconnectDurationLimitLatestTimestamp: number | undefined;
|
|
718
719
|
constructor(hostName: string, optionsOverrides?: any, glitchFree?: boolean, disconnectDurationLimitOn?: boolean);
|
|
719
|
-
_didExceedDisconnectDurationLimit(
|
|
720
|
-
|
|
720
|
+
_didExceedDisconnectDurationLimit(timestamp: number | undefined): boolean;
|
|
721
|
+
enableDisconnectDurationLimit(): void;
|
|
721
722
|
setRtcManager(rtcManager?: RtcManager): void;
|
|
722
723
|
connect(): void;
|
|
723
724
|
disconnect(): void;
|
|
@@ -1226,6 +1227,7 @@ declare class P2pRtcManager implements RtcManager {
|
|
|
1226
1227
|
_closed: boolean;
|
|
1227
1228
|
skipEmittingServerMessageCount: number;
|
|
1228
1229
|
analytics: P2PAnalytics;
|
|
1230
|
+
_rtcStatsDisconnectTimeout?: ReturnType<typeof setTimeout>;
|
|
1229
1231
|
constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, }: {
|
|
1230
1232
|
selfId: any;
|
|
1231
1233
|
room: any;
|
|
@@ -1595,7 +1597,7 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1595
1597
|
_socketListenerDeregisterFunctions: any;
|
|
1596
1598
|
_reconnect: any;
|
|
1597
1599
|
_reconnectTimeOut: any;
|
|
1598
|
-
_qualityMonitor:
|
|
1600
|
+
_qualityMonitor: VegaMediaQualityMonitor;
|
|
1599
1601
|
_fetchMediaServersTimer: any;
|
|
1600
1602
|
_iceServers: any;
|
|
1601
1603
|
_turnServers: any;
|
package/dist/index.mjs
CHANGED
|
@@ -1545,6 +1545,7 @@ var _a$6;
|
|
|
1545
1545
|
const adapter$6 = (_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6 : adapterRaw;
|
|
1546
1546
|
const DEFAULT_SOCKET_PATH = "/protocol/socket.io/v4";
|
|
1547
1547
|
const NOOP_KEEPALIVE_INTERVAL = 2000;
|
|
1548
|
+
const DISCONNECT_DURATION_LIMIT_MS = 60000;
|
|
1548
1549
|
class ServerSocket {
|
|
1549
1550
|
constructor(hostName, optionsOverrides, glitchFree = false, disconnectDurationLimitOn = false) {
|
|
1550
1551
|
this._wasConnectedUsingWebsocket = false;
|
|
@@ -1552,21 +1553,22 @@ class ServerSocket {
|
|
|
1552
1553
|
this.disconnectDurationLimitExceeded = false;
|
|
1553
1554
|
this._reconnectManager = null;
|
|
1554
1555
|
this._socket = io(hostName, Object.assign({ path: DEFAULT_SOCKET_PATH, randomizationFactor: 0.5, reconnectionDelay: 250, reconnectionDelayMax: 5000, timeout: 5000, transports: ["websocket"], withCredentials: true }, optionsOverrides));
|
|
1556
|
+
this._disconnectDurationLimitEnabled = false;
|
|
1555
1557
|
this.joinRoomFinished = false;
|
|
1556
1558
|
this._socket.io.on("reconnect", () => {
|
|
1557
|
-
if (this._disconnectDurationLimitOn &&
|
|
1559
|
+
if (this._disconnectDurationLimitOn &&
|
|
1560
|
+
this._didExceedDisconnectDurationLimit(this._disconnectDurationLimitLatestTimestamp)) {
|
|
1558
1561
|
this._socket.close();
|
|
1559
1562
|
this.disconnectDurationLimitExceeded = true;
|
|
1560
|
-
return;
|
|
1561
1563
|
}
|
|
1562
1564
|
this._socket.sendBuffer = [];
|
|
1563
1565
|
});
|
|
1564
1566
|
this._socket.io.on("reconnect_attempt", () => {
|
|
1565
1567
|
var _a;
|
|
1566
|
-
if (this._disconnectDurationLimitOn &&
|
|
1568
|
+
if (this._disconnectDurationLimitOn &&
|
|
1569
|
+
this._didExceedDisconnectDurationLimit(this._disconnectDurationLimitLatestTimestamp)) {
|
|
1567
1570
|
this._socket.close();
|
|
1568
1571
|
this.disconnectDurationLimitExceeded = true;
|
|
1569
|
-
return;
|
|
1570
1572
|
}
|
|
1571
1573
|
if (this._wasConnectedUsingWebsocket) {
|
|
1572
1574
|
this._socket.io.opts.transports = ["websocket"];
|
|
@@ -1590,25 +1592,30 @@ class ServerSocket {
|
|
|
1590
1592
|
const transport = this.getTransport();
|
|
1591
1593
|
if (transport === "websocket") {
|
|
1592
1594
|
this._wasConnectedUsingWebsocket = true;
|
|
1593
|
-
if (!this.noopKeepaliveInterval)
|
|
1595
|
+
if (!this.noopKeepaliveInterval) {
|
|
1596
|
+
let disconnectDurationLimitTimestampCandidate = Date.now();
|
|
1594
1597
|
this.noopKeepaliveInterval = setInterval(() => {
|
|
1595
1598
|
try {
|
|
1596
1599
|
if (this._socket.connected) {
|
|
1597
|
-
if (this._disconnectDurationLimitOn
|
|
1598
|
-
this.
|
|
1600
|
+
if (this._disconnectDurationLimitOn &&
|
|
1601
|
+
!this._didExceedDisconnectDurationLimit(disconnectDurationLimitTimestampCandidate)) {
|
|
1602
|
+
this._disconnectDurationLimitLatestTimestamp =
|
|
1603
|
+
disconnectDurationLimitTimestampCandidate;
|
|
1604
|
+
disconnectDurationLimitTimestampCandidate = Date.now();
|
|
1599
1605
|
}
|
|
1600
1606
|
this._socket.io.engine.sendPacket("noop");
|
|
1601
1607
|
}
|
|
1602
1608
|
}
|
|
1603
1609
|
catch (ex) { }
|
|
1604
1610
|
}, NOOP_KEEPALIVE_INTERVAL);
|
|
1611
|
+
}
|
|
1605
1612
|
}
|
|
1606
1613
|
});
|
|
1607
1614
|
this._socket.on("disconnect", () => {
|
|
1608
|
-
if (this._disconnectDurationLimitOn &&
|
|
1615
|
+
if (this._disconnectDurationLimitOn &&
|
|
1616
|
+
this._didExceedDisconnectDurationLimit(this._disconnectDurationLimitLatestTimestamp)) {
|
|
1609
1617
|
this._socket.close();
|
|
1610
1618
|
this.disconnectDurationLimitExceeded = true;
|
|
1611
|
-
return;
|
|
1612
1619
|
}
|
|
1613
1620
|
this.joinRoomFinished = false;
|
|
1614
1621
|
this.disconnectTimestamp = Date.now();
|
|
@@ -1618,20 +1625,18 @@ class ServerSocket {
|
|
|
1618
1625
|
}
|
|
1619
1626
|
});
|
|
1620
1627
|
}
|
|
1621
|
-
_didExceedDisconnectDurationLimit() {
|
|
1622
|
-
if (!this._disconnectDurationLimitOn)
|
|
1623
|
-
return false;
|
|
1624
|
-
if (this._disconnectDurationLimitInMs && this._noopKeepaliveTimestamp) {
|
|
1625
|
-
const disconnectedDuration = Date.now() - this._noopKeepaliveTimestamp;
|
|
1626
|
-
if (disconnectedDuration > this._disconnectDurationLimitInMs) {
|
|
1627
|
-
return true;
|
|
1628
|
-
}
|
|
1628
|
+
_didExceedDisconnectDurationLimit(timestamp) {
|
|
1629
|
+
if (!timestamp || !this._disconnectDurationLimitOn || !this._disconnectDurationLimitEnabled)
|
|
1629
1630
|
return false;
|
|
1631
|
+
const disconnectedDuration = Date.now() - timestamp;
|
|
1632
|
+
if (disconnectedDuration > DISCONNECT_DURATION_LIMIT_MS) {
|
|
1633
|
+
return true;
|
|
1630
1634
|
}
|
|
1635
|
+
return false;
|
|
1631
1636
|
}
|
|
1632
|
-
|
|
1637
|
+
enableDisconnectDurationLimit() {
|
|
1633
1638
|
if (this._disconnectDurationLimitOn) {
|
|
1634
|
-
this.
|
|
1639
|
+
this._disconnectDurationLimitEnabled = true;
|
|
1635
1640
|
}
|
|
1636
1641
|
}
|
|
1637
1642
|
setRtcManager(rtcManager) {
|
|
@@ -2776,6 +2781,7 @@ class P2pRtcManager {
|
|
|
2776
2781
|
this._localStreamDeregisterFunction();
|
|
2777
2782
|
this._localStreamDeregisterFunction = null;
|
|
2778
2783
|
}
|
|
2784
|
+
this.rtcStatsDisconnect();
|
|
2779
2785
|
}
|
|
2780
2786
|
setupSocketListeners() {
|
|
2781
2787
|
this._socketListenerDeregisterFunctions = [
|
|
@@ -2878,6 +2884,7 @@ class P2pRtcManager {
|
|
|
2878
2884
|
}
|
|
2879
2885
|
}
|
|
2880
2886
|
rtcStatsDisconnect() {
|
|
2887
|
+
clearTimeout(this._rtcStatsDisconnectTimeout);
|
|
2881
2888
|
rtcStats.server.close();
|
|
2882
2889
|
}
|
|
2883
2890
|
rtcStatsReconnect() {
|
|
@@ -3603,7 +3610,7 @@ class P2pRtcManager {
|
|
|
3603
3610
|
this._changeBandwidthForAllClients(false);
|
|
3604
3611
|
const numPeers = this.numberOfPeerconnections();
|
|
3605
3612
|
if (numPeers === 0) {
|
|
3606
|
-
setTimeout(() => {
|
|
3613
|
+
this._rtcStatsDisconnectTimeout = setTimeout(() => {
|
|
3607
3614
|
const numPeers = this.numberOfPeerconnections();
|
|
3608
3615
|
if (numPeers === 0) {
|
|
3609
3616
|
this.rtcStatsDisconnect();
|
|
@@ -5702,6 +5709,7 @@ class VegaRtcManager {
|
|
|
5702
5709
|
this._screenAudioTrack = null;
|
|
5703
5710
|
this._streamIdToVideoConsumerId.clear();
|
|
5704
5711
|
this._mediasoupDeviceInitializedAsync = Promise.resolve(null);
|
|
5712
|
+
this._qualityMonitor.close();
|
|
5705
5713
|
}
|
|
5706
5714
|
sendAudioMutedStats(muted) {
|
|
5707
5715
|
rtcStats.sendEvent("audio_muted", { muted });
|
package/dist/legacy-esm.js
CHANGED
|
@@ -1545,6 +1545,7 @@ var _a$6;
|
|
|
1545
1545
|
const adapter$6 = (_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6 : adapterRaw;
|
|
1546
1546
|
const DEFAULT_SOCKET_PATH = "/protocol/socket.io/v4";
|
|
1547
1547
|
const NOOP_KEEPALIVE_INTERVAL = 2000;
|
|
1548
|
+
const DISCONNECT_DURATION_LIMIT_MS = 60000;
|
|
1548
1549
|
class ServerSocket {
|
|
1549
1550
|
constructor(hostName, optionsOverrides, glitchFree = false, disconnectDurationLimitOn = false) {
|
|
1550
1551
|
this._wasConnectedUsingWebsocket = false;
|
|
@@ -1552,21 +1553,22 @@ class ServerSocket {
|
|
|
1552
1553
|
this.disconnectDurationLimitExceeded = false;
|
|
1553
1554
|
this._reconnectManager = null;
|
|
1554
1555
|
this._socket = io(hostName, Object.assign({ path: DEFAULT_SOCKET_PATH, randomizationFactor: 0.5, reconnectionDelay: 250, reconnectionDelayMax: 5000, timeout: 5000, transports: ["websocket"], withCredentials: true }, optionsOverrides));
|
|
1556
|
+
this._disconnectDurationLimitEnabled = false;
|
|
1555
1557
|
this.joinRoomFinished = false;
|
|
1556
1558
|
this._socket.io.on("reconnect", () => {
|
|
1557
|
-
if (this._disconnectDurationLimitOn &&
|
|
1559
|
+
if (this._disconnectDurationLimitOn &&
|
|
1560
|
+
this._didExceedDisconnectDurationLimit(this._disconnectDurationLimitLatestTimestamp)) {
|
|
1558
1561
|
this._socket.close();
|
|
1559
1562
|
this.disconnectDurationLimitExceeded = true;
|
|
1560
|
-
return;
|
|
1561
1563
|
}
|
|
1562
1564
|
this._socket.sendBuffer = [];
|
|
1563
1565
|
});
|
|
1564
1566
|
this._socket.io.on("reconnect_attempt", () => {
|
|
1565
1567
|
var _a;
|
|
1566
|
-
if (this._disconnectDurationLimitOn &&
|
|
1568
|
+
if (this._disconnectDurationLimitOn &&
|
|
1569
|
+
this._didExceedDisconnectDurationLimit(this._disconnectDurationLimitLatestTimestamp)) {
|
|
1567
1570
|
this._socket.close();
|
|
1568
1571
|
this.disconnectDurationLimitExceeded = true;
|
|
1569
|
-
return;
|
|
1570
1572
|
}
|
|
1571
1573
|
if (this._wasConnectedUsingWebsocket) {
|
|
1572
1574
|
this._socket.io.opts.transports = ["websocket"];
|
|
@@ -1590,25 +1592,30 @@ class ServerSocket {
|
|
|
1590
1592
|
const transport = this.getTransport();
|
|
1591
1593
|
if (transport === "websocket") {
|
|
1592
1594
|
this._wasConnectedUsingWebsocket = true;
|
|
1593
|
-
if (!this.noopKeepaliveInterval)
|
|
1595
|
+
if (!this.noopKeepaliveInterval) {
|
|
1596
|
+
let disconnectDurationLimitTimestampCandidate = Date.now();
|
|
1594
1597
|
this.noopKeepaliveInterval = setInterval(() => {
|
|
1595
1598
|
try {
|
|
1596
1599
|
if (this._socket.connected) {
|
|
1597
|
-
if (this._disconnectDurationLimitOn
|
|
1598
|
-
this.
|
|
1600
|
+
if (this._disconnectDurationLimitOn &&
|
|
1601
|
+
!this._didExceedDisconnectDurationLimit(disconnectDurationLimitTimestampCandidate)) {
|
|
1602
|
+
this._disconnectDurationLimitLatestTimestamp =
|
|
1603
|
+
disconnectDurationLimitTimestampCandidate;
|
|
1604
|
+
disconnectDurationLimitTimestampCandidate = Date.now();
|
|
1599
1605
|
}
|
|
1600
1606
|
this._socket.io.engine.sendPacket("noop");
|
|
1601
1607
|
}
|
|
1602
1608
|
}
|
|
1603
1609
|
catch (ex) { }
|
|
1604
1610
|
}, NOOP_KEEPALIVE_INTERVAL);
|
|
1611
|
+
}
|
|
1605
1612
|
}
|
|
1606
1613
|
});
|
|
1607
1614
|
this._socket.on("disconnect", () => {
|
|
1608
|
-
if (this._disconnectDurationLimitOn &&
|
|
1615
|
+
if (this._disconnectDurationLimitOn &&
|
|
1616
|
+
this._didExceedDisconnectDurationLimit(this._disconnectDurationLimitLatestTimestamp)) {
|
|
1609
1617
|
this._socket.close();
|
|
1610
1618
|
this.disconnectDurationLimitExceeded = true;
|
|
1611
|
-
return;
|
|
1612
1619
|
}
|
|
1613
1620
|
this.joinRoomFinished = false;
|
|
1614
1621
|
this.disconnectTimestamp = Date.now();
|
|
@@ -1618,20 +1625,18 @@ class ServerSocket {
|
|
|
1618
1625
|
}
|
|
1619
1626
|
});
|
|
1620
1627
|
}
|
|
1621
|
-
_didExceedDisconnectDurationLimit() {
|
|
1622
|
-
if (!this._disconnectDurationLimitOn)
|
|
1623
|
-
return false;
|
|
1624
|
-
if (this._disconnectDurationLimitInMs && this._noopKeepaliveTimestamp) {
|
|
1625
|
-
const disconnectedDuration = Date.now() - this._noopKeepaliveTimestamp;
|
|
1626
|
-
if (disconnectedDuration > this._disconnectDurationLimitInMs) {
|
|
1627
|
-
return true;
|
|
1628
|
-
}
|
|
1628
|
+
_didExceedDisconnectDurationLimit(timestamp) {
|
|
1629
|
+
if (!timestamp || !this._disconnectDurationLimitOn || !this._disconnectDurationLimitEnabled)
|
|
1629
1630
|
return false;
|
|
1631
|
+
const disconnectedDuration = Date.now() - timestamp;
|
|
1632
|
+
if (disconnectedDuration > DISCONNECT_DURATION_LIMIT_MS) {
|
|
1633
|
+
return true;
|
|
1630
1634
|
}
|
|
1635
|
+
return false;
|
|
1631
1636
|
}
|
|
1632
|
-
|
|
1637
|
+
enableDisconnectDurationLimit() {
|
|
1633
1638
|
if (this._disconnectDurationLimitOn) {
|
|
1634
|
-
this.
|
|
1639
|
+
this._disconnectDurationLimitEnabled = true;
|
|
1635
1640
|
}
|
|
1636
1641
|
}
|
|
1637
1642
|
setRtcManager(rtcManager) {
|
|
@@ -2776,6 +2781,7 @@ class P2pRtcManager {
|
|
|
2776
2781
|
this._localStreamDeregisterFunction();
|
|
2777
2782
|
this._localStreamDeregisterFunction = null;
|
|
2778
2783
|
}
|
|
2784
|
+
this.rtcStatsDisconnect();
|
|
2779
2785
|
}
|
|
2780
2786
|
setupSocketListeners() {
|
|
2781
2787
|
this._socketListenerDeregisterFunctions = [
|
|
@@ -2878,6 +2884,7 @@ class P2pRtcManager {
|
|
|
2878
2884
|
}
|
|
2879
2885
|
}
|
|
2880
2886
|
rtcStatsDisconnect() {
|
|
2887
|
+
clearTimeout(this._rtcStatsDisconnectTimeout);
|
|
2881
2888
|
rtcStats.server.close();
|
|
2882
2889
|
}
|
|
2883
2890
|
rtcStatsReconnect() {
|
|
@@ -3603,7 +3610,7 @@ class P2pRtcManager {
|
|
|
3603
3610
|
this._changeBandwidthForAllClients(false);
|
|
3604
3611
|
const numPeers = this.numberOfPeerconnections();
|
|
3605
3612
|
if (numPeers === 0) {
|
|
3606
|
-
setTimeout(() => {
|
|
3613
|
+
this._rtcStatsDisconnectTimeout = setTimeout(() => {
|
|
3607
3614
|
const numPeers = this.numberOfPeerconnections();
|
|
3608
3615
|
if (numPeers === 0) {
|
|
3609
3616
|
this.rtcStatsDisconnect();
|
|
@@ -5702,6 +5709,7 @@ class VegaRtcManager {
|
|
|
5702
5709
|
this._screenAudioTrack = null;
|
|
5703
5710
|
this._streamIdToVideoConsumerId.clear();
|
|
5704
5711
|
this._mediasoupDeviceInitializedAsync = Promise.resolve(null);
|
|
5712
|
+
this._qualityMonitor.close();
|
|
5705
5713
|
}
|
|
5706
5714
|
sendAudioMutedStats(muted) {
|
|
5707
5715
|
rtcStats.sendEvent("audio_muted", { muted });
|