@koi-design/callkit 2.0.0 → 2.0.2
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.d.ts +1 -0
- package/dist/index.global.js +37 -20
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +37 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -587,7 +587,7 @@ var Call = class {
|
|
|
587
587
|
// package.json
|
|
588
588
|
var package_default = {
|
|
589
589
|
name: "@koi-design/callkit",
|
|
590
|
-
version: "2.0.
|
|
590
|
+
version: "2.0.2",
|
|
591
591
|
description: "callkit",
|
|
592
592
|
author: "koi",
|
|
593
593
|
license: "ISC",
|
|
@@ -644,7 +644,7 @@ var Config = class {
|
|
|
644
644
|
this.callKit = callKit;
|
|
645
645
|
}
|
|
646
646
|
config = {
|
|
647
|
-
version: `
|
|
647
|
+
version: `V${package_default.version}`,
|
|
648
648
|
host: "",
|
|
649
649
|
log: "info",
|
|
650
650
|
trackLogs: trackLogsDefaultConfig,
|
|
@@ -1476,14 +1476,11 @@ var Connect = class {
|
|
|
1476
1476
|
caller: "Connect.register",
|
|
1477
1477
|
type: "SIP",
|
|
1478
1478
|
content: {
|
|
1479
|
-
version:
|
|
1479
|
+
version: `${this.callKit.config.getConfig().version}`
|
|
1480
1480
|
}
|
|
1481
1481
|
});
|
|
1482
|
-
const version = `V${this.callKit.config.getConfig().version}`;
|
|
1483
1482
|
await this.registerer.register().then(() => {
|
|
1484
|
-
this.callKit.socket.send(SocketSendEvent.START
|
|
1485
|
-
version
|
|
1486
|
-
});
|
|
1483
|
+
this.callKit.socket.send(SocketSendEvent.START);
|
|
1487
1484
|
}).catch(async (err) => {
|
|
1488
1485
|
this.callKit.reset();
|
|
1489
1486
|
this.callKit.logger.error(err?.message, {
|
|
@@ -1900,9 +1897,33 @@ var Socket = class {
|
|
|
1900
1897
|
});
|
|
1901
1898
|
return;
|
|
1902
1899
|
}
|
|
1900
|
+
if (this.isReconnecting) {
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
1903
|
this.attemptReconnect();
|
|
1904
1904
|
}
|
|
1905
|
+
clearWebSocket() {
|
|
1906
|
+
if (this.ws) {
|
|
1907
|
+
this.ws.onopen = null;
|
|
1908
|
+
this.ws.onclose = null;
|
|
1909
|
+
this.ws.onerror = null;
|
|
1910
|
+
this.ws.onmessage = null;
|
|
1911
|
+
}
|
|
1912
|
+
if (this.ws.readyState === WebSocket.CONNECTING || this.ws.readyState === WebSocket.OPEN) {
|
|
1913
|
+
this.ws.close();
|
|
1914
|
+
this.callKit.logger.info("socket clear", {
|
|
1915
|
+
caller: "Socket.clearWebSocket",
|
|
1916
|
+
type: "INCALL",
|
|
1917
|
+
content: {}
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
this.ws = void 0;
|
|
1921
|
+
this.isConnected = false;
|
|
1922
|
+
}
|
|
1905
1923
|
connect(socketUrl) {
|
|
1924
|
+
if (this.ws) {
|
|
1925
|
+
this.clearWebSocket();
|
|
1926
|
+
}
|
|
1906
1927
|
this.ws = new WebSocket(socketUrl);
|
|
1907
1928
|
this.ws.onopen = (ev) => this.onOpen(ev);
|
|
1908
1929
|
this.ws.onclose = (ev) => this.onClose(ev);
|
|
@@ -1948,10 +1969,6 @@ var Socket = class {
|
|
|
1948
1969
|
type: "INCALL",
|
|
1949
1970
|
content: { ev }
|
|
1950
1971
|
});
|
|
1951
|
-
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
1952
|
-
event: "INCALL_CONNECT_ERROR",
|
|
1953
|
-
err: ev
|
|
1954
|
-
});
|
|
1955
1972
|
if (this.socketError) {
|
|
1956
1973
|
return;
|
|
1957
1974
|
}
|
|
@@ -1959,6 +1976,10 @@ var Socket = class {
|
|
|
1959
1976
|
}
|
|
1960
1977
|
onError(ev) {
|
|
1961
1978
|
this.socketError = true;
|
|
1979
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
1980
|
+
event: "INCALL_CONNECT_ERROR",
|
|
1981
|
+
err: ev
|
|
1982
|
+
});
|
|
1962
1983
|
this.callKit.logger.error("socket onError", {
|
|
1963
1984
|
caller: "Socket.onError",
|
|
1964
1985
|
type: "INCALL",
|
|
@@ -2280,17 +2301,13 @@ var Socket = class {
|
|
|
2280
2301
|
this.lastPingTime = void 0;
|
|
2281
2302
|
this.satrtConfirm = false;
|
|
2282
2303
|
this.socketError = false;
|
|
2283
|
-
|
|
2284
|
-
this.callKit.logger.info("Closing socket connection", {
|
|
2285
|
-
caller: "Socket.reset",
|
|
2286
|
-
type: "INCALL",
|
|
2287
|
-
content: {}
|
|
2288
|
-
});
|
|
2289
|
-
this.ws.close();
|
|
2290
|
-
this.isConnected = false;
|
|
2291
|
-
}
|
|
2304
|
+
this.clearWebSocket();
|
|
2292
2305
|
}
|
|
2293
2306
|
attemptReconnect() {
|
|
2307
|
+
if (this.reconnectTimer) {
|
|
2308
|
+
clearTimeout(this.reconnectTimer);
|
|
2309
|
+
this.reconnectTimer = void 0;
|
|
2310
|
+
}
|
|
2294
2311
|
if (this.reconnectAttempts >= this.socketConfig.maxAttempts) {
|
|
2295
2312
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
2296
2313
|
event: "INCALL_RECONNECT_ERROR"
|