@whereby.com/media 2.5.4 → 2.5.5
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 +37 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +37 -1
- package/dist/legacy-esm.js +37 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1566,16 +1566,28 @@ const adapter$6 = (_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6
|
|
|
1566
1566
|
const DEFAULT_SOCKET_PATH = "/protocol/socket.io/v4";
|
|
1567
1567
|
const NOOP_KEEPALIVE_INTERVAL = 2000;
|
|
1568
1568
|
class ServerSocket {
|
|
1569
|
-
constructor(hostName, optionsOverrides, glitchFree = false) {
|
|
1569
|
+
constructor(hostName, optionsOverrides, glitchFree = false, disconnectDurationLimitOn = false) {
|
|
1570
1570
|
this._wasConnectedUsingWebsocket = false;
|
|
1571
|
+
this._disconnectDurationLimitOn = disconnectDurationLimitOn;
|
|
1572
|
+
this.disconnectDurationLimitExceeded = false;
|
|
1571
1573
|
this._reconnectManager = null;
|
|
1572
1574
|
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));
|
|
1573
1575
|
this.joinRoomFinished = false;
|
|
1574
1576
|
this._socket.io.on("reconnect", () => {
|
|
1577
|
+
if (this._disconnectDurationLimitOn && this._didExceedDisconnectDurationLimit()) {
|
|
1578
|
+
this._socket.close();
|
|
1579
|
+
this.disconnectDurationLimitExceeded = true;
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1575
1582
|
this._socket.sendBuffer = [];
|
|
1576
1583
|
});
|
|
1577
1584
|
this._socket.io.on("reconnect_attempt", () => {
|
|
1578
1585
|
var _a;
|
|
1586
|
+
if (this._disconnectDurationLimitOn && this._didExceedDisconnectDurationLimit()) {
|
|
1587
|
+
this._socket.close();
|
|
1588
|
+
this.disconnectDurationLimitExceeded = true;
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1579
1591
|
if (this._wasConnectedUsingWebsocket) {
|
|
1580
1592
|
this._socket.io.opts.transports = ["websocket"];
|
|
1581
1593
|
if (((_a = adapter$6.browserDetails) === null || _a === void 0 ? void 0 : _a.browser) !== "safari") {
|
|
@@ -1602,6 +1614,9 @@ class ServerSocket {
|
|
|
1602
1614
|
this.noopKeepaliveInterval = setInterval(() => {
|
|
1603
1615
|
try {
|
|
1604
1616
|
if (this._socket.connected) {
|
|
1617
|
+
if (this._disconnectDurationLimitOn) {
|
|
1618
|
+
this._noopKeepaliveTimestamp = Date.now();
|
|
1619
|
+
}
|
|
1605
1620
|
this._socket.io.engine.sendPacket("noop");
|
|
1606
1621
|
}
|
|
1607
1622
|
}
|
|
@@ -1610,6 +1625,11 @@ class ServerSocket {
|
|
|
1610
1625
|
}
|
|
1611
1626
|
});
|
|
1612
1627
|
this._socket.on("disconnect", () => {
|
|
1628
|
+
if (this._disconnectDurationLimitOn && this._didExceedDisconnectDurationLimit()) {
|
|
1629
|
+
this._socket.close();
|
|
1630
|
+
this.disconnectDurationLimitExceeded = true;
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1613
1633
|
this.joinRoomFinished = false;
|
|
1614
1634
|
this.disconnectTimestamp = Date.now();
|
|
1615
1635
|
if (this.noopKeepaliveInterval) {
|
|
@@ -1618,6 +1638,22 @@ class ServerSocket {
|
|
|
1618
1638
|
}
|
|
1619
1639
|
});
|
|
1620
1640
|
}
|
|
1641
|
+
_didExceedDisconnectDurationLimit() {
|
|
1642
|
+
if (!this._disconnectDurationLimitOn)
|
|
1643
|
+
return false;
|
|
1644
|
+
if (this._disconnectDurationLimitInMs && this._noopKeepaliveTimestamp) {
|
|
1645
|
+
const disconnectedDuration = Date.now() - this._noopKeepaliveTimestamp;
|
|
1646
|
+
if (disconnectedDuration > this._disconnectDurationLimitInMs) {
|
|
1647
|
+
return true;
|
|
1648
|
+
}
|
|
1649
|
+
return false;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
setDisconnectDurationLimit(limitInMs) {
|
|
1653
|
+
if (this._disconnectDurationLimitOn) {
|
|
1654
|
+
this._disconnectDurationLimitInMs = limitInMs;
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1621
1657
|
setRtcManager(rtcManager) {
|
|
1622
1658
|
if (this._reconnectManager) {
|
|
1623
1659
|
this._reconnectManager.rtcManager = rtcManager;
|
package/dist/index.d.cts
CHANGED
|
@@ -638,10 +638,16 @@ declare class ServerSocket {
|
|
|
638
638
|
_socket: any;
|
|
639
639
|
_reconnectManager?: ReconnectManager | null;
|
|
640
640
|
noopKeepaliveInterval: any;
|
|
641
|
+
_noopKeepaliveTimestamp: number | undefined;
|
|
641
642
|
_wasConnectedUsingWebsocket?: boolean;
|
|
642
643
|
disconnectTimestamp: number | undefined;
|
|
644
|
+
disconnectDurationLimitExceeded: boolean;
|
|
643
645
|
joinRoomFinished: boolean;
|
|
644
|
-
|
|
646
|
+
_disconnectDurationLimitOn: boolean;
|
|
647
|
+
_disconnectDurationLimitInMs: number | undefined;
|
|
648
|
+
constructor(hostName: string, optionsOverrides?: any, glitchFree?: boolean, disconnectDurationLimitOn?: boolean);
|
|
649
|
+
_didExceedDisconnectDurationLimit(): boolean | undefined;
|
|
650
|
+
setDisconnectDurationLimit(limitInMs: number): void;
|
|
645
651
|
setRtcManager(rtcManager?: RtcManager): void;
|
|
646
652
|
connect(): void;
|
|
647
653
|
disconnect(): void;
|
package/dist/index.d.mts
CHANGED
|
@@ -638,10 +638,16 @@ declare class ServerSocket {
|
|
|
638
638
|
_socket: any;
|
|
639
639
|
_reconnectManager?: ReconnectManager | null;
|
|
640
640
|
noopKeepaliveInterval: any;
|
|
641
|
+
_noopKeepaliveTimestamp: number | undefined;
|
|
641
642
|
_wasConnectedUsingWebsocket?: boolean;
|
|
642
643
|
disconnectTimestamp: number | undefined;
|
|
644
|
+
disconnectDurationLimitExceeded: boolean;
|
|
643
645
|
joinRoomFinished: boolean;
|
|
644
|
-
|
|
646
|
+
_disconnectDurationLimitOn: boolean;
|
|
647
|
+
_disconnectDurationLimitInMs: number | undefined;
|
|
648
|
+
constructor(hostName: string, optionsOverrides?: any, glitchFree?: boolean, disconnectDurationLimitOn?: boolean);
|
|
649
|
+
_didExceedDisconnectDurationLimit(): boolean | undefined;
|
|
650
|
+
setDisconnectDurationLimit(limitInMs: number): void;
|
|
645
651
|
setRtcManager(rtcManager?: RtcManager): void;
|
|
646
652
|
connect(): void;
|
|
647
653
|
disconnect(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -638,10 +638,16 @@ declare class ServerSocket {
|
|
|
638
638
|
_socket: any;
|
|
639
639
|
_reconnectManager?: ReconnectManager | null;
|
|
640
640
|
noopKeepaliveInterval: any;
|
|
641
|
+
_noopKeepaliveTimestamp: number | undefined;
|
|
641
642
|
_wasConnectedUsingWebsocket?: boolean;
|
|
642
643
|
disconnectTimestamp: number | undefined;
|
|
644
|
+
disconnectDurationLimitExceeded: boolean;
|
|
643
645
|
joinRoomFinished: boolean;
|
|
644
|
-
|
|
646
|
+
_disconnectDurationLimitOn: boolean;
|
|
647
|
+
_disconnectDurationLimitInMs: number | undefined;
|
|
648
|
+
constructor(hostName: string, optionsOverrides?: any, glitchFree?: boolean, disconnectDurationLimitOn?: boolean);
|
|
649
|
+
_didExceedDisconnectDurationLimit(): boolean | undefined;
|
|
650
|
+
setDisconnectDurationLimit(limitInMs: number): void;
|
|
645
651
|
setRtcManager(rtcManager?: RtcManager): void;
|
|
646
652
|
connect(): void;
|
|
647
653
|
disconnect(): void;
|
package/dist/index.mjs
CHANGED
|
@@ -1545,16 +1545,28 @@ const adapter$6 = (_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6
|
|
|
1545
1545
|
const DEFAULT_SOCKET_PATH = "/protocol/socket.io/v4";
|
|
1546
1546
|
const NOOP_KEEPALIVE_INTERVAL = 2000;
|
|
1547
1547
|
class ServerSocket {
|
|
1548
|
-
constructor(hostName, optionsOverrides, glitchFree = false) {
|
|
1548
|
+
constructor(hostName, optionsOverrides, glitchFree = false, disconnectDurationLimitOn = false) {
|
|
1549
1549
|
this._wasConnectedUsingWebsocket = false;
|
|
1550
|
+
this._disconnectDurationLimitOn = disconnectDurationLimitOn;
|
|
1551
|
+
this.disconnectDurationLimitExceeded = false;
|
|
1550
1552
|
this._reconnectManager = null;
|
|
1551
1553
|
this._socket = io(hostName, Object.assign({ path: DEFAULT_SOCKET_PATH, randomizationFactor: 0.5, reconnectionDelay: 250, reconnectionDelayMax: 5000, timeout: 5000, transports: ["websocket"], withCredentials: true }, optionsOverrides));
|
|
1552
1554
|
this.joinRoomFinished = false;
|
|
1553
1555
|
this._socket.io.on("reconnect", () => {
|
|
1556
|
+
if (this._disconnectDurationLimitOn && this._didExceedDisconnectDurationLimit()) {
|
|
1557
|
+
this._socket.close();
|
|
1558
|
+
this.disconnectDurationLimitExceeded = true;
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1554
1561
|
this._socket.sendBuffer = [];
|
|
1555
1562
|
});
|
|
1556
1563
|
this._socket.io.on("reconnect_attempt", () => {
|
|
1557
1564
|
var _a;
|
|
1565
|
+
if (this._disconnectDurationLimitOn && this._didExceedDisconnectDurationLimit()) {
|
|
1566
|
+
this._socket.close();
|
|
1567
|
+
this.disconnectDurationLimitExceeded = true;
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1558
1570
|
if (this._wasConnectedUsingWebsocket) {
|
|
1559
1571
|
this._socket.io.opts.transports = ["websocket"];
|
|
1560
1572
|
if (((_a = adapter$6.browserDetails) === null || _a === void 0 ? void 0 : _a.browser) !== "safari") {
|
|
@@ -1581,6 +1593,9 @@ class ServerSocket {
|
|
|
1581
1593
|
this.noopKeepaliveInterval = setInterval(() => {
|
|
1582
1594
|
try {
|
|
1583
1595
|
if (this._socket.connected) {
|
|
1596
|
+
if (this._disconnectDurationLimitOn) {
|
|
1597
|
+
this._noopKeepaliveTimestamp = Date.now();
|
|
1598
|
+
}
|
|
1584
1599
|
this._socket.io.engine.sendPacket("noop");
|
|
1585
1600
|
}
|
|
1586
1601
|
}
|
|
@@ -1589,6 +1604,11 @@ class ServerSocket {
|
|
|
1589
1604
|
}
|
|
1590
1605
|
});
|
|
1591
1606
|
this._socket.on("disconnect", () => {
|
|
1607
|
+
if (this._disconnectDurationLimitOn && this._didExceedDisconnectDurationLimit()) {
|
|
1608
|
+
this._socket.close();
|
|
1609
|
+
this.disconnectDurationLimitExceeded = true;
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1592
1612
|
this.joinRoomFinished = false;
|
|
1593
1613
|
this.disconnectTimestamp = Date.now();
|
|
1594
1614
|
if (this.noopKeepaliveInterval) {
|
|
@@ -1597,6 +1617,22 @@ class ServerSocket {
|
|
|
1597
1617
|
}
|
|
1598
1618
|
});
|
|
1599
1619
|
}
|
|
1620
|
+
_didExceedDisconnectDurationLimit() {
|
|
1621
|
+
if (!this._disconnectDurationLimitOn)
|
|
1622
|
+
return false;
|
|
1623
|
+
if (this._disconnectDurationLimitInMs && this._noopKeepaliveTimestamp) {
|
|
1624
|
+
const disconnectedDuration = Date.now() - this._noopKeepaliveTimestamp;
|
|
1625
|
+
if (disconnectedDuration > this._disconnectDurationLimitInMs) {
|
|
1626
|
+
return true;
|
|
1627
|
+
}
|
|
1628
|
+
return false;
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
setDisconnectDurationLimit(limitInMs) {
|
|
1632
|
+
if (this._disconnectDurationLimitOn) {
|
|
1633
|
+
this._disconnectDurationLimitInMs = limitInMs;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1600
1636
|
setRtcManager(rtcManager) {
|
|
1601
1637
|
if (this._reconnectManager) {
|
|
1602
1638
|
this._reconnectManager.rtcManager = rtcManager;
|
package/dist/legacy-esm.js
CHANGED
|
@@ -1545,16 +1545,28 @@ const adapter$6 = (_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6
|
|
|
1545
1545
|
const DEFAULT_SOCKET_PATH = "/protocol/socket.io/v4";
|
|
1546
1546
|
const NOOP_KEEPALIVE_INTERVAL = 2000;
|
|
1547
1547
|
class ServerSocket {
|
|
1548
|
-
constructor(hostName, optionsOverrides, glitchFree = false) {
|
|
1548
|
+
constructor(hostName, optionsOverrides, glitchFree = false, disconnectDurationLimitOn = false) {
|
|
1549
1549
|
this._wasConnectedUsingWebsocket = false;
|
|
1550
|
+
this._disconnectDurationLimitOn = disconnectDurationLimitOn;
|
|
1551
|
+
this.disconnectDurationLimitExceeded = false;
|
|
1550
1552
|
this._reconnectManager = null;
|
|
1551
1553
|
this._socket = io(hostName, Object.assign({ path: DEFAULT_SOCKET_PATH, randomizationFactor: 0.5, reconnectionDelay: 250, reconnectionDelayMax: 5000, timeout: 5000, transports: ["websocket"], withCredentials: true }, optionsOverrides));
|
|
1552
1554
|
this.joinRoomFinished = false;
|
|
1553
1555
|
this._socket.io.on("reconnect", () => {
|
|
1556
|
+
if (this._disconnectDurationLimitOn && this._didExceedDisconnectDurationLimit()) {
|
|
1557
|
+
this._socket.close();
|
|
1558
|
+
this.disconnectDurationLimitExceeded = true;
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1554
1561
|
this._socket.sendBuffer = [];
|
|
1555
1562
|
});
|
|
1556
1563
|
this._socket.io.on("reconnect_attempt", () => {
|
|
1557
1564
|
var _a;
|
|
1565
|
+
if (this._disconnectDurationLimitOn && this._didExceedDisconnectDurationLimit()) {
|
|
1566
|
+
this._socket.close();
|
|
1567
|
+
this.disconnectDurationLimitExceeded = true;
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1558
1570
|
if (this._wasConnectedUsingWebsocket) {
|
|
1559
1571
|
this._socket.io.opts.transports = ["websocket"];
|
|
1560
1572
|
if (((_a = adapter$6.browserDetails) === null || _a === void 0 ? void 0 : _a.browser) !== "safari") {
|
|
@@ -1581,6 +1593,9 @@ class ServerSocket {
|
|
|
1581
1593
|
this.noopKeepaliveInterval = setInterval(() => {
|
|
1582
1594
|
try {
|
|
1583
1595
|
if (this._socket.connected) {
|
|
1596
|
+
if (this._disconnectDurationLimitOn) {
|
|
1597
|
+
this._noopKeepaliveTimestamp = Date.now();
|
|
1598
|
+
}
|
|
1584
1599
|
this._socket.io.engine.sendPacket("noop");
|
|
1585
1600
|
}
|
|
1586
1601
|
}
|
|
@@ -1589,6 +1604,11 @@ class ServerSocket {
|
|
|
1589
1604
|
}
|
|
1590
1605
|
});
|
|
1591
1606
|
this._socket.on("disconnect", () => {
|
|
1607
|
+
if (this._disconnectDurationLimitOn && this._didExceedDisconnectDurationLimit()) {
|
|
1608
|
+
this._socket.close();
|
|
1609
|
+
this.disconnectDurationLimitExceeded = true;
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1592
1612
|
this.joinRoomFinished = false;
|
|
1593
1613
|
this.disconnectTimestamp = Date.now();
|
|
1594
1614
|
if (this.noopKeepaliveInterval) {
|
|
@@ -1597,6 +1617,22 @@ class ServerSocket {
|
|
|
1597
1617
|
}
|
|
1598
1618
|
});
|
|
1599
1619
|
}
|
|
1620
|
+
_didExceedDisconnectDurationLimit() {
|
|
1621
|
+
if (!this._disconnectDurationLimitOn)
|
|
1622
|
+
return false;
|
|
1623
|
+
if (this._disconnectDurationLimitInMs && this._noopKeepaliveTimestamp) {
|
|
1624
|
+
const disconnectedDuration = Date.now() - this._noopKeepaliveTimestamp;
|
|
1625
|
+
if (disconnectedDuration > this._disconnectDurationLimitInMs) {
|
|
1626
|
+
return true;
|
|
1627
|
+
}
|
|
1628
|
+
return false;
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
setDisconnectDurationLimit(limitInMs) {
|
|
1632
|
+
if (this._disconnectDurationLimitOn) {
|
|
1633
|
+
this._disconnectDurationLimitInMs = limitInMs;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1600
1636
|
setRtcManager(rtcManager) {
|
|
1601
1637
|
if (this._reconnectManager) {
|
|
1602
1638
|
this._reconnectManager.rtcManager = rtcManager;
|
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": "2.5.
|
|
4
|
+
"version": "2.5.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/whereby/sdk",
|
|
7
7
|
"repository": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@whereby.com/eslint-config": "0.1.0",
|
|
65
65
|
"@whereby.com/jest-config": "0.1.0",
|
|
66
66
|
"@whereby.com/prettier-config": "0.1.0",
|
|
67
|
-
"@whereby.com/rollup-config": "0.1.
|
|
67
|
+
"@whereby.com/rollup-config": "0.1.1",
|
|
68
68
|
"@whereby.com/tsconfig": "0.1.0"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|