@koi-design/callkit 2.0.0-beta.4 → 2.0.0-beta.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.d.ts +4 -3
- package/dist/index.global.js +33 -15
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +33 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/index.mjs
CHANGED
|
@@ -210,7 +210,8 @@ var KitEvent = {
|
|
|
210
210
|
* User status change
|
|
211
211
|
*/
|
|
212
212
|
USER_STATUS_CHANGE: "userStatusChange",
|
|
213
|
-
|
|
213
|
+
INCALL_CONNECT_EVENT: "IncallConnectEvent",
|
|
214
|
+
SIP_CONNECT_EVENT: "sipConnectEvent",
|
|
214
215
|
SIP_REGISTERER_EVENT: "sipRegistererEvent",
|
|
215
216
|
SIP_SESSION_EVENT: "sipSessionEvent"
|
|
216
217
|
};
|
|
@@ -535,7 +536,7 @@ var Call = class {
|
|
|
535
536
|
});
|
|
536
537
|
return;
|
|
537
538
|
}
|
|
538
|
-
this.callKit.connect.setHold(
|
|
539
|
+
this.callKit.connect.setHold(false);
|
|
539
540
|
}
|
|
540
541
|
async callMute() {
|
|
541
542
|
if (!this.callKit.config.check())
|
|
@@ -898,7 +899,7 @@ var Connect = class {
|
|
|
898
899
|
if (this.connectStatus !== CallStatus.init) {
|
|
899
900
|
this.setConnectStatus(CallStatus.init);
|
|
900
901
|
}
|
|
901
|
-
if (this.isRegistered) {
|
|
902
|
+
if (this.isRegistered()) {
|
|
902
903
|
this.unregister();
|
|
903
904
|
}
|
|
904
905
|
this.currentSession = void 0;
|
|
@@ -1002,7 +1003,7 @@ var Connect = class {
|
|
|
1002
1003
|
this.heartbeatFlag -= 1;
|
|
1003
1004
|
if (this.heartbeatFlag <= 0) {
|
|
1004
1005
|
this.heartbeatFlag = MAX_HEARTBEAT_COUNT;
|
|
1005
|
-
this.callKit.trigger(KitEvent.
|
|
1006
|
+
this.callKit.trigger(KitEvent.SIP_CONNECT_EVENT, {
|
|
1006
1007
|
event: "OPTIONS_HEARTBEAT_EXPIRED"
|
|
1007
1008
|
});
|
|
1008
1009
|
}
|
|
@@ -1166,6 +1167,10 @@ var Connect = class {
|
|
|
1166
1167
|
}
|
|
1167
1168
|
});
|
|
1168
1169
|
this.setRegister(true);
|
|
1170
|
+
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1171
|
+
registererState: state,
|
|
1172
|
+
isRegistered: this.isRegistered()
|
|
1173
|
+
});
|
|
1169
1174
|
break;
|
|
1170
1175
|
case RegistererState.Terminated:
|
|
1171
1176
|
this.callKit.logger.info("registerer stateChange Terminated", {
|
|
@@ -1178,6 +1183,10 @@ var Connect = class {
|
|
|
1178
1183
|
});
|
|
1179
1184
|
this.setRegister(false);
|
|
1180
1185
|
this.setConnectStatus(CallStatus.init);
|
|
1186
|
+
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1187
|
+
registererState: state,
|
|
1188
|
+
isRegistered: this.isRegistered()
|
|
1189
|
+
});
|
|
1181
1190
|
break;
|
|
1182
1191
|
case RegistererState.Unregistered:
|
|
1183
1192
|
this.callKit.logger.info("registerer stateChange Unregistered", {
|
|
@@ -1190,6 +1199,10 @@ var Connect = class {
|
|
|
1190
1199
|
});
|
|
1191
1200
|
this.setRegister(false);
|
|
1192
1201
|
this.setConnectStatus(CallStatus.init);
|
|
1202
|
+
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1203
|
+
registererState: state,
|
|
1204
|
+
isRegistered: this.isRegistered()
|
|
1205
|
+
});
|
|
1193
1206
|
break;
|
|
1194
1207
|
default:
|
|
1195
1208
|
break;
|
|
@@ -1279,7 +1292,6 @@ var Connect = class {
|
|
|
1279
1292
|
};
|
|
1280
1293
|
if (this.isOutgoing) {
|
|
1281
1294
|
this.currentSession.accept(options);
|
|
1282
|
-
this.setConnectStatus(CallStatus.connecting);
|
|
1283
1295
|
this.callKit.trigger(KitEvent.KIT_OUTGOING_INVITE, {
|
|
1284
1296
|
getInviteData: () => {
|
|
1285
1297
|
const { request: request2 } = this.currentSession;
|
|
@@ -1760,7 +1772,7 @@ var Connect = class {
|
|
|
1760
1772
|
// package/socket.ts
|
|
1761
1773
|
var RECONNECT_CONFIG = {
|
|
1762
1774
|
enabled: true,
|
|
1763
|
-
maxAttempts:
|
|
1775
|
+
maxAttempts: 3,
|
|
1764
1776
|
delay: 500,
|
|
1765
1777
|
backoffMultiplier: 1.5,
|
|
1766
1778
|
pingInterval: 3e4,
|
|
@@ -1778,6 +1790,7 @@ var Socket = class {
|
|
|
1778
1790
|
reconnectTimer;
|
|
1779
1791
|
isReconnecting = false;
|
|
1780
1792
|
reconnectAttempts = 0;
|
|
1793
|
+
socketError = false;
|
|
1781
1794
|
constructor(callKit) {
|
|
1782
1795
|
this.callKit = callKit;
|
|
1783
1796
|
const { reconnect } = this.callKit.config.getConfig();
|
|
@@ -1801,7 +1814,7 @@ var Socket = class {
|
|
|
1801
1814
|
this.isConnected = false;
|
|
1802
1815
|
if (!this.callKit.config.isLogin() || !this.socketConfig.enabled) {
|
|
1803
1816
|
this.reset();
|
|
1804
|
-
this.callKit.trigger(KitEvent.
|
|
1817
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
1805
1818
|
event: "INCALL_NOT_CONNECTED"
|
|
1806
1819
|
});
|
|
1807
1820
|
return;
|
|
@@ -1821,6 +1834,7 @@ var Socket = class {
|
|
|
1821
1834
|
type: "INCALL",
|
|
1822
1835
|
content: { ev }
|
|
1823
1836
|
});
|
|
1837
|
+
this.socketError = false;
|
|
1824
1838
|
this.isConnected = true;
|
|
1825
1839
|
this.lastPingTime = Date.now();
|
|
1826
1840
|
this.checkPing();
|
|
@@ -1833,7 +1847,7 @@ var Socket = class {
|
|
|
1833
1847
|
reconnectAttempts: this.reconnectAttempts
|
|
1834
1848
|
}
|
|
1835
1849
|
});
|
|
1836
|
-
this.callKit.trigger(KitEvent.
|
|
1850
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
1837
1851
|
event: "INCALL_RECONNECT_SUCCESS"
|
|
1838
1852
|
});
|
|
1839
1853
|
}
|
|
@@ -1853,10 +1867,13 @@ var Socket = class {
|
|
|
1853
1867
|
type: "INCALL",
|
|
1854
1868
|
content: { ev }
|
|
1855
1869
|
});
|
|
1856
|
-
this.callKit.trigger(KitEvent.
|
|
1870
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
1857
1871
|
event: "INCALL_CONNECT_ERROR",
|
|
1858
1872
|
err: ev
|
|
1859
1873
|
});
|
|
1874
|
+
if (this.socketError) {
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1860
1877
|
this.handleDisconnect();
|
|
1861
1878
|
}
|
|
1862
1879
|
onError(ev) {
|
|
@@ -1868,6 +1885,7 @@ var Socket = class {
|
|
|
1868
1885
|
data: ev
|
|
1869
1886
|
}
|
|
1870
1887
|
});
|
|
1888
|
+
this.socketError = true;
|
|
1871
1889
|
}
|
|
1872
1890
|
confirmAck(data) {
|
|
1873
1891
|
const { ack, messageId } = data;
|
|
@@ -2025,7 +2043,7 @@ var Socket = class {
|
|
|
2025
2043
|
}
|
|
2026
2044
|
send(event, message) {
|
|
2027
2045
|
if (!this.isConnected) {
|
|
2028
|
-
this.callKit.trigger(KitEvent.
|
|
2046
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
2029
2047
|
event: "INCALL_NOT_CONNECTED"
|
|
2030
2048
|
});
|
|
2031
2049
|
this.callKit.logger.error("socket not connected", {
|
|
@@ -2084,7 +2102,7 @@ var Socket = class {
|
|
|
2084
2102
|
}
|
|
2085
2103
|
async sendMessage(event, message) {
|
|
2086
2104
|
if (!this.isConnected) {
|
|
2087
|
-
this.callKit.trigger(KitEvent.
|
|
2105
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
2088
2106
|
event: "INCALL_NOT_CONNECTED"
|
|
2089
2107
|
});
|
|
2090
2108
|
this.callKit.logger.error("socket not connected", {
|
|
@@ -2138,8 +2156,7 @@ var Socket = class {
|
|
|
2138
2156
|
}, this.socketConfig.pingInterval);
|
|
2139
2157
|
}
|
|
2140
2158
|
/**
|
|
2141
|
-
*
|
|
2142
|
-
* @param isWaitConfirm Whether need to wait for close confirmation
|
|
2159
|
+
* reset socket connection and all states
|
|
2143
2160
|
*/
|
|
2144
2161
|
async reset() {
|
|
2145
2162
|
if (this.pingTimer) {
|
|
@@ -2149,6 +2166,7 @@ var Socket = class {
|
|
|
2149
2166
|
this.resetReconnectState();
|
|
2150
2167
|
this.lastPingTime = void 0;
|
|
2151
2168
|
this.satrtConfirm = false;
|
|
2169
|
+
this.socketError = false;
|
|
2152
2170
|
if (this.ws && this.isConnected) {
|
|
2153
2171
|
this.callKit.logger.info("Closing socket connection", {
|
|
2154
2172
|
caller: "Socket.reset",
|
|
@@ -2169,14 +2187,14 @@ var Socket = class {
|
|
|
2169
2187
|
reconnectAttempts: this.reconnectAttempts
|
|
2170
2188
|
}
|
|
2171
2189
|
});
|
|
2172
|
-
this.callKit.trigger(KitEvent.
|
|
2190
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
2173
2191
|
event: "INCALL_RECONNECT_ERROR"
|
|
2174
2192
|
});
|
|
2175
2193
|
this.reset();
|
|
2176
2194
|
return;
|
|
2177
2195
|
}
|
|
2178
2196
|
if (this.reconnectAttempts === 0) {
|
|
2179
|
-
this.callKit.trigger(KitEvent.
|
|
2197
|
+
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
2180
2198
|
event: "INCALL_RECONNECT_START"
|
|
2181
2199
|
});
|
|
2182
2200
|
}
|