@koi-design/callkit 2.0.5-beta.1 → 2.0.5-beta.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 +7 -6
- package/dist/index.global.js +44 -35
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +44 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -60,6 +60,10 @@ var Api = class {
|
|
|
60
60
|
isLoginOuting = false;
|
|
61
61
|
async login(params) {
|
|
62
62
|
if (this.isLogining) {
|
|
63
|
+
this.callKit.logger.info("login is already in progress cancel", {
|
|
64
|
+
caller: "Api.login",
|
|
65
|
+
content: { userName: params.userName }
|
|
66
|
+
});
|
|
63
67
|
return;
|
|
64
68
|
}
|
|
65
69
|
this.isLogining = true;
|
|
@@ -69,15 +73,17 @@ var Api = class {
|
|
|
69
73
|
method: "post",
|
|
70
74
|
data: params
|
|
71
75
|
});
|
|
72
|
-
this.isLogining = false;
|
|
73
76
|
return res;
|
|
74
|
-
}
|
|
77
|
+
} finally {
|
|
75
78
|
this.isLogining = false;
|
|
76
|
-
throw error;
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
async loginOut(params) {
|
|
80
82
|
if (this.isLoginOuting) {
|
|
83
|
+
this.callKit.logger.info("loginOut is already in progress cancel", {
|
|
84
|
+
caller: "Api.loginOut",
|
|
85
|
+
content: { sessionId: params.sessionId }
|
|
86
|
+
});
|
|
81
87
|
return;
|
|
82
88
|
}
|
|
83
89
|
this.isLoginOuting = true;
|
|
@@ -87,11 +93,9 @@ var Api = class {
|
|
|
87
93
|
method: "post",
|
|
88
94
|
data: params
|
|
89
95
|
});
|
|
90
|
-
this.isLoginOuting = false;
|
|
91
96
|
return res;
|
|
92
|
-
}
|
|
97
|
+
} finally {
|
|
93
98
|
this.isLoginOuting = false;
|
|
94
|
-
throw error;
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
101
|
async trackLogs(log) {
|
|
@@ -528,14 +532,14 @@ var Call = class {
|
|
|
528
532
|
this.callKit.logger.info("callStart", {
|
|
529
533
|
caller: "Call.callStart",
|
|
530
534
|
content: {
|
|
531
|
-
startConfirm: this.callKit.socket.
|
|
535
|
+
startConfirm: this.callKit.socket.startConfirm
|
|
532
536
|
}
|
|
533
537
|
});
|
|
534
|
-
if (!this.callKit.socket.
|
|
538
|
+
if (!this.callKit.socket.startConfirm) {
|
|
535
539
|
this.callKit.logger.warn("server not confirm start", {
|
|
536
540
|
caller: "Call.callStart",
|
|
537
541
|
content: {
|
|
538
|
-
startConfirm: this.callKit.socket.
|
|
542
|
+
startConfirm: this.callKit.socket.startConfirm
|
|
539
543
|
}
|
|
540
544
|
});
|
|
541
545
|
return;
|
|
@@ -657,7 +661,7 @@ var Call = class {
|
|
|
657
661
|
// package.json
|
|
658
662
|
var package_default = {
|
|
659
663
|
name: "@koi-design/callkit",
|
|
660
|
-
version: "2.0.5-beta.
|
|
664
|
+
version: "2.0.5-beta.2",
|
|
661
665
|
description: "callkit",
|
|
662
666
|
author: "koi",
|
|
663
667
|
license: "ISC",
|
|
@@ -1548,9 +1552,7 @@ var Connect = class {
|
|
|
1548
1552
|
version: `${this.callKit.config.getConfig().version}`
|
|
1549
1553
|
}
|
|
1550
1554
|
});
|
|
1551
|
-
await this.registerer.register().
|
|
1552
|
-
this.callKit.socket.send(SocketSendEvent.START);
|
|
1553
|
-
}).catch(async (err) => {
|
|
1555
|
+
await this.registerer.register().catch(async (err) => {
|
|
1554
1556
|
this.callKit.reset();
|
|
1555
1557
|
this.callKit.logger.error(err?.message, {
|
|
1556
1558
|
caller: "Connect.register",
|
|
@@ -1949,7 +1951,7 @@ var Socket = class {
|
|
|
1949
1951
|
/**
|
|
1950
1952
|
* @description connect auth state
|
|
1951
1953
|
* @default {
|
|
1952
|
-
*
|
|
1954
|
+
* startConfirm: false,
|
|
1953
1955
|
* isConnected: false,
|
|
1954
1956
|
* isReconnecting: false,
|
|
1955
1957
|
* isAuthenticated: false,
|
|
@@ -1957,14 +1959,13 @@ var Socket = class {
|
|
|
1957
1959
|
* }
|
|
1958
1960
|
*/
|
|
1959
1961
|
connectAuthState = {
|
|
1960
|
-
|
|
1962
|
+
startConfirm: false,
|
|
1961
1963
|
isConnected: false,
|
|
1962
1964
|
isReconnecting: false,
|
|
1963
|
-
isAuthenticated: false,
|
|
1964
1965
|
isError: false
|
|
1965
1966
|
};
|
|
1966
|
-
get
|
|
1967
|
-
return this.connectAuthState.
|
|
1967
|
+
get startConfirm() {
|
|
1968
|
+
return this.connectAuthState.startConfirm;
|
|
1968
1969
|
}
|
|
1969
1970
|
get isError() {
|
|
1970
1971
|
return this.connectAuthState.isError;
|
|
@@ -2004,6 +2005,9 @@ var Socket = class {
|
|
|
2004
2005
|
if (this.connectAuthState.isReconnecting) {
|
|
2005
2006
|
return;
|
|
2006
2007
|
}
|
|
2008
|
+
if (this.connectAuthState.isError) {
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2007
2011
|
this.attemptReconnect();
|
|
2008
2012
|
}
|
|
2009
2013
|
clearWebSocket() {
|
|
@@ -2043,6 +2047,7 @@ var Socket = class {
|
|
|
2043
2047
|
this.setConnectAuthState("isConnected", true);
|
|
2044
2048
|
this.lastPingTime = Date.now();
|
|
2045
2049
|
this.checkPing();
|
|
2050
|
+
this.send(SocketSendEvent.START);
|
|
2046
2051
|
if (this.connectAuthState.isReconnecting) {
|
|
2047
2052
|
this.setConnectAuthState("isReconnecting", false);
|
|
2048
2053
|
this.callKit.logger.info("reconnect success", {
|
|
@@ -2058,19 +2063,23 @@ var Socket = class {
|
|
|
2058
2063
|
});
|
|
2059
2064
|
}
|
|
2060
2065
|
}
|
|
2066
|
+
cleanReconnectState() {
|
|
2067
|
+
this.reconnectAttempts = 0;
|
|
2068
|
+
if (this.reconnectTimer) {
|
|
2069
|
+
clearTimeout(this.reconnectTimer);
|
|
2070
|
+
this.reconnectTimer = void 0;
|
|
2071
|
+
}
|
|
2072
|
+
this.setConnectAuthState("isReconnecting", false);
|
|
2073
|
+
this.setConnectAuthState("isError", false);
|
|
2074
|
+
}
|
|
2061
2075
|
resetConnectState() {
|
|
2062
2076
|
this.connectAuthState = {
|
|
2063
|
-
|
|
2077
|
+
startConfirm: false,
|
|
2064
2078
|
isConnected: false,
|
|
2065
2079
|
isReconnecting: false,
|
|
2066
|
-
isAuthenticated: false,
|
|
2067
2080
|
isError: false
|
|
2068
2081
|
};
|
|
2069
|
-
this.
|
|
2070
|
-
if (this.reconnectTimer) {
|
|
2071
|
-
clearTimeout(this.reconnectTimer);
|
|
2072
|
-
this.reconnectTimer = void 0;
|
|
2073
|
-
}
|
|
2082
|
+
this.cleanReconnectState();
|
|
2074
2083
|
this.callKit.logger.info("reset connect state", {
|
|
2075
2084
|
caller: "Socket.resetConnectState",
|
|
2076
2085
|
type: "INCALL",
|
|
@@ -2141,7 +2150,8 @@ var Socket = class {
|
|
|
2141
2150
|
return;
|
|
2142
2151
|
}
|
|
2143
2152
|
if (data.event === SocketReceiveEvent.START_CONFIRM) {
|
|
2144
|
-
this.setConnectAuthState("
|
|
2153
|
+
this.setConnectAuthState("startConfirm", true);
|
|
2154
|
+
this.cleanReconnectState();
|
|
2145
2155
|
}
|
|
2146
2156
|
if (data.event === SocketReceiveEvent.CUSTOMER_RINGING) {
|
|
2147
2157
|
this.callKit.trigger(KitEvent.CALL_RINGING, /* @__PURE__ */ new Date());
|
|
@@ -2296,20 +2306,19 @@ var Socket = class {
|
|
|
2296
2306
|
* reset socket connection and all states
|
|
2297
2307
|
*/
|
|
2298
2308
|
async reset(config) {
|
|
2299
|
-
const {
|
|
2309
|
+
const { force = false } = config || {};
|
|
2300
2310
|
if (this.pingTimer) {
|
|
2301
2311
|
clearInterval(this.pingTimer);
|
|
2302
2312
|
this.pingTimer = void 0;
|
|
2303
2313
|
}
|
|
2304
|
-
if (
|
|
2314
|
+
if (force) {
|
|
2305
2315
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
2306
2316
|
event: "INCALL_RESET"
|
|
2307
2317
|
});
|
|
2308
2318
|
this.resetConnectState();
|
|
2309
|
-
this.setConnectAuthState("isConnected", false);
|
|
2310
2319
|
}
|
|
2311
2320
|
this.lastPingTime = void 0;
|
|
2312
|
-
this.setConnectAuthState("
|
|
2321
|
+
this.setConnectAuthState("startConfirm", false);
|
|
2313
2322
|
this.clearWebSocket();
|
|
2314
2323
|
}
|
|
2315
2324
|
attemptReconnect() {
|
|
@@ -2660,16 +2669,16 @@ var CallKit = class {
|
|
|
2660
2669
|
/**
|
|
2661
2670
|
* reset callkit
|
|
2662
2671
|
* @description recover the callkit to the initial state
|
|
2663
|
-
* @default
|
|
2664
|
-
* @param config.
|
|
2672
|
+
* @default force is false
|
|
2673
|
+
* @param config.force is true, the callkit reset socket connection and all states
|
|
2665
2674
|
*/
|
|
2666
2675
|
async reset(config) {
|
|
2667
|
-
const {
|
|
2676
|
+
const { force = false } = config || {};
|
|
2668
2677
|
this.logger.info("reset", {
|
|
2669
2678
|
caller: "CallKit.reset",
|
|
2670
2679
|
content: {
|
|
2671
2680
|
connectStatus: this.connect.connectStatus,
|
|
2672
|
-
|
|
2681
|
+
force
|
|
2673
2682
|
}
|
|
2674
2683
|
});
|
|
2675
2684
|
if (this.connect.isCalling()) {
|
|
@@ -2681,7 +2690,7 @@ var CallKit = class {
|
|
|
2681
2690
|
} else {
|
|
2682
2691
|
await this.config.reset();
|
|
2683
2692
|
}
|
|
2684
|
-
await this.socket.reset({
|
|
2693
|
+
await this.socket.reset({ force });
|
|
2685
2694
|
}
|
|
2686
2695
|
on(event, callback) {
|
|
2687
2696
|
this.listener.push({
|