webitel-sdk 0.1.84 → 0.1.85
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/bundles/index.esm.js +19 -0
- package/bundles/index.esm.js.map +1 -1
- package/bundles/index.esm.min.js +1 -1
- package/bundles/index.esm.min.js.map +1 -1
- package/bundles/index.umd.js +44 -4
- package/bundles/index.umd.js.map +1 -1
- package/bundles/index.umd.min.js +1 -1
- package/bundles/index.umd.min.js.map +1 -1
- package/esm2015/socket/client.js +19 -0
- package/esm2015/socket/client.js.map +1 -1
- package/esm5/socket/client.js +44 -4
- package/esm5/socket/client.js.map +1 -1
- package/package.json +1 -1
- package/types/socket/client.d.ts +4 -0
- package/types/socket/client.d.ts.map +1 -1
package/bundles/index.esm.js
CHANGED
|
@@ -23387,6 +23387,7 @@ const API_HEADER_TOKEN = 'X-Webitel-Access';
|
|
|
23387
23387
|
const WEBSOCKET_AUTHENTICATION_CHALLENGE = 'authentication_challenge';
|
|
23388
23388
|
const WEBSOCKET_DEFAULT_DEVICE_CONFIG = 'user_default_device';
|
|
23389
23389
|
const WEBSOCKET_AGENT_SESSION = 'cc_agent_session';
|
|
23390
|
+
const WEBSOCKET_PING = 'ping';
|
|
23390
23391
|
// const WEBSOCKET_CALL_BY_USER = 'call_by_user'
|
|
23391
23392
|
const WEBSOCKET_MAKE_OUTBOUND_CALL = 'call_invite';
|
|
23392
23393
|
const WEBSOCKET_MAKE_USER_CALL = 'call_user';
|
|
@@ -23413,6 +23414,7 @@ class Client extends EventEmitter {
|
|
|
23413
23414
|
this.eventHandler = new EventEmitter();
|
|
23414
23415
|
this.callStore = new Map();
|
|
23415
23416
|
this.conversationStore = new Map();
|
|
23417
|
+
this.pingTimer = null;
|
|
23416
23418
|
this.basePath = `${formatBaseUri(_config.storageEndpoint || _config.endpoint)}`;
|
|
23417
23419
|
}
|
|
23418
23420
|
async connect() {
|
|
@@ -23575,6 +23577,11 @@ class Client extends EventEmitter {
|
|
|
23575
23577
|
token: this._config.token,
|
|
23576
23578
|
});
|
|
23577
23579
|
}
|
|
23580
|
+
async ping() {
|
|
23581
|
+
return this.request(WEBSOCKET_PING, {
|
|
23582
|
+
ping: 1,
|
|
23583
|
+
});
|
|
23584
|
+
}
|
|
23578
23585
|
sessionInfo() {
|
|
23579
23586
|
return this.connectionInfo.session;
|
|
23580
23587
|
}
|
|
@@ -23813,8 +23820,20 @@ class Client extends EventEmitter {
|
|
|
23813
23820
|
this.eventHandler.emit(TASK_EVENT, e.status, task);
|
|
23814
23821
|
}
|
|
23815
23822
|
}
|
|
23823
|
+
async pingServer() {
|
|
23824
|
+
if (this.pingTimer) {
|
|
23825
|
+
await this.ping();
|
|
23826
|
+
}
|
|
23827
|
+
if (this.connectionInfo.ping_interval) {
|
|
23828
|
+
// @ts-ignore
|
|
23829
|
+
this.pingTimer = setTimeout(this.pingServer.bind(this), +this.connectionInfo.ping_interval);
|
|
23830
|
+
}
|
|
23831
|
+
}
|
|
23816
23832
|
async connected(info) {
|
|
23817
23833
|
this.connectionInfo = info;
|
|
23834
|
+
if (info.ping_interval) {
|
|
23835
|
+
await this.pingServer();
|
|
23836
|
+
}
|
|
23818
23837
|
if (!this.useWebPhone()) {
|
|
23819
23838
|
return;
|
|
23820
23839
|
}
|