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.
@@ -26512,6 +26512,7 @@
26512
26512
  var WEBSOCKET_AUTHENTICATION_CHALLENGE = 'authentication_challenge';
26513
26513
  var WEBSOCKET_DEFAULT_DEVICE_CONFIG = 'user_default_device';
26514
26514
  var WEBSOCKET_AGENT_SESSION = 'cc_agent_session';
26515
+ var WEBSOCKET_PING = 'ping';
26515
26516
  // const WEBSOCKET_CALL_BY_USER = 'call_by_user'
26516
26517
  var WEBSOCKET_MAKE_OUTBOUND_CALL = 'call_invite';
26517
26518
  var WEBSOCKET_MAKE_USER_CALL = 'call_user';
@@ -26538,6 +26539,7 @@
26538
26539
  _this.eventHandler = new eeTs.EventEmitter();
26539
26540
  _this.callStore = new Map();
26540
26541
  _this.conversationStore = new Map();
26542
+ _this.pingTimer = null;
26541
26543
  _this.basePath = "" + formatBaseUri(_config.storageEndpoint || _config.endpoint);
26542
26544
  return _this;
26543
26545
  }
@@ -26787,6 +26789,15 @@
26787
26789
  });
26788
26790
  });
26789
26791
  };
26792
+ Client.prototype.ping = function () {
26793
+ return tslib.__awaiter(this, void 0, void 0, function () {
26794
+ return tslib.__generator(this, function (_a) {
26795
+ return [2 /*return*/, this.request(WEBSOCKET_PING, {
26796
+ ping: 1,
26797
+ })];
26798
+ });
26799
+ });
26800
+ };
26790
26801
  Client.prototype.sessionInfo = function () {
26791
26802
  return this.connectionInfo.session;
26792
26803
  };
@@ -27147,14 +27158,43 @@
27147
27158
  this.eventHandler.emit(TASK_EVENT, e.status, task);
27148
27159
  }
27149
27160
  };
27161
+ Client.prototype.pingServer = function () {
27162
+ return tslib.__awaiter(this, void 0, void 0, function () {
27163
+ return tslib.__generator(this, function (_a) {
27164
+ switch (_a.label) {
27165
+ case 0:
27166
+ if (!this.pingTimer) return [3 /*break*/, 2];
27167
+ return [4 /*yield*/, this.ping()];
27168
+ case 1:
27169
+ _a.sent();
27170
+ _a.label = 2;
27171
+ case 2:
27172
+ if (this.connectionInfo.ping_interval) {
27173
+ // @ts-ignore
27174
+ this.pingTimer = setTimeout(this.pingServer.bind(this), +this.connectionInfo.ping_interval);
27175
+ }
27176
+ return [2 /*return*/];
27177
+ }
27178
+ });
27179
+ });
27180
+ };
27150
27181
  Client.prototype.connected = function (info) {
27151
27182
  return tslib.__awaiter(this, void 0, void 0, function () {
27152
27183
  return tslib.__generator(this, function (_a) {
27153
- this.connectionInfo = info;
27154
- if (!this.useWebPhone()) {
27155
- return [2 /*return*/];
27184
+ switch (_a.label) {
27185
+ case 0:
27186
+ this.connectionInfo = info;
27187
+ if (!info.ping_interval) return [3 /*break*/, 2];
27188
+ return [4 /*yield*/, this.pingServer()];
27189
+ case 1:
27190
+ _a.sent();
27191
+ _a.label = 2;
27192
+ case 2:
27193
+ if (!this.useWebPhone()) {
27194
+ return [2 /*return*/];
27195
+ }
27196
+ return [2 /*return*/, this.registerCallClient(new SipPhone(this.instanceId, this._config.debug))];
27156
27197
  }
27157
- return [2 /*return*/, this.registerCallClient(new SipPhone(this.instanceId, this._config.debug))];
27158
27198
  });
27159
27199
  });
27160
27200
  };