@webex/calling 3.12.0-llmrefactor.1 → 3.12.0-llmrefactor.11
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/CallingClient/CallingClient.js +17 -11
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +383 -185
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +1 -1
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +545 -513
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/constants.js +4 -2
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +4 -0
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +47 -10
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +555 -409
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +636 -81
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js +26 -0
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/Errors/types.js +2 -0
- package/dist/Errors/types.js.map +1 -1
- package/dist/Events/types.js.map +1 -1
- package/dist/common/Utils.js +68 -44
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +267 -195
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/module/CallingClient/CallingClient.js +11 -10
- package/dist/module/CallingClient/calling/call.js +3 -1
- package/dist/module/CallingClient/constants.js +2 -0
- package/dist/module/CallingClient/line/index.js +2 -0
- package/dist/module/CallingClient/registration/register.js +65 -14
- package/dist/module/CallingClient/registration/types.js +5 -1
- package/dist/module/Errors/types.js +2 -0
- package/dist/module/common/Utils.js +15 -2
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +2 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +3 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +22 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/Errors/types.d.ts +2 -0
- package/dist/types/Errors/types.d.ts.map +1 -1
- package/dist/types/Events/types.d.ts +1 -1
- package/dist/types/Events/types.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +2 -5
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -32,10 +32,12 @@ var _types = require("../../Metrics/types");
|
|
|
32
32
|
var _Metrics = require("../../Metrics");
|
|
33
33
|
var _calling = require("../calling");
|
|
34
34
|
var _Logger = _interopRequireDefault(require("../../Logger"));
|
|
35
|
+
var _types2 = require("./types");
|
|
35
36
|
var _SDKConnector = _interopRequireDefault(require("../../SDKConnector"));
|
|
36
|
-
var
|
|
37
|
+
var _types3 = require("../../common/types");
|
|
37
38
|
var _constants2 = require("../constants");
|
|
38
|
-
var
|
|
39
|
+
var _types4 = require("../line/types");
|
|
40
|
+
var _types5 = require("../../Errors/types");
|
|
39
41
|
var _request = require("../utils/request");
|
|
40
42
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof _Symbol && r[_Symbol$iterator] || r["@@iterator"]; if (!t) { if (_Array$isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
41
43
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? _Array$from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -75,17 +77,24 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
75
77
|
(0, _defineProperty2.default)(this, "retryAfter", void 0);
|
|
76
78
|
(0, _defineProperty2.default)(this, "scheduled429Retry", false);
|
|
77
79
|
(0, _defineProperty2.default)(this, "webWorker", void 0);
|
|
80
|
+
/**
|
|
81
|
+
* Set once Mobius reports this session as superseded by another registration for the
|
|
82
|
+
* same user. It survives cleanup so that no automatic recovery path re-registers this
|
|
83
|
+
* device, which would restart the registration ping-pong between the two sessions.
|
|
84
|
+
* Only an explicit `triggerRegistration()` from the consumer clears it.
|
|
85
|
+
*/
|
|
86
|
+
(0, _defineProperty2.default)(this, "sessionSuperseded", false);
|
|
78
87
|
(0, _defineProperty2.default)(this, "apiRequest", void 0);
|
|
79
88
|
this.jwe = jwe;
|
|
80
89
|
this.sdkConnector = _SDKConnector.default;
|
|
81
90
|
this.serviceData = serviceData;
|
|
82
|
-
this.isCCFlow = serviceData.indicator ===
|
|
91
|
+
this.isCCFlow = serviceData.indicator === _types3.ServiceIndicator.CONTACT_CENTER;
|
|
83
92
|
if (!this.sdkConnector.getWebex()) {
|
|
84
93
|
_SDKConnector.default.setWebex(webex);
|
|
85
94
|
}
|
|
86
95
|
this.webex = this.sdkConnector.getWebex();
|
|
87
96
|
this.userId = this.webex.internal.device.userId;
|
|
88
|
-
this.registrationStatus =
|
|
97
|
+
this.registrationStatus = _types3.RegistrationStatus.IDLE;
|
|
89
98
|
this.failback429RetryAttempts = 0;
|
|
90
99
|
_Logger.default.setLogger(logLevel, _constants2.REGISTRATION_FILE);
|
|
91
100
|
this.rehomingIntervalMin = _constants2.DEFAULT_REHOMING_INTERVAL_MIN;
|
|
@@ -235,9 +244,9 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
235
244
|
case 0:
|
|
236
245
|
requestObj = {
|
|
237
246
|
uri: "".concat(url).concat(_constants2.DEVICES_ENDPOINT_RESOURCE, "/").concat(deviceId),
|
|
238
|
-
method:
|
|
247
|
+
method: _types3.HTTP_METHODS.DELETE,
|
|
239
248
|
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceUrl), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
|
|
240
|
-
service:
|
|
249
|
+
service: _types3.ALLOWED_SERVICES.MOBIUS
|
|
241
250
|
};
|
|
242
251
|
if (this.apiRequest.isSocketEnabled()) {
|
|
243
252
|
// @ts-ignore - body is added for mobius wss support, it is not used for mobius http
|
|
@@ -262,8 +271,8 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
262
271
|
_context2.next = 4;
|
|
263
272
|
return (0, _common.uploadLogs)();
|
|
264
273
|
case 4:
|
|
265
|
-
this.setStatus(
|
|
266
|
-
this.lineEmitter(
|
|
274
|
+
this.setStatus(_types3.RegistrationStatus.INACTIVE);
|
|
275
|
+
this.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
|
|
267
276
|
return _context2.abrupt("return", response);
|
|
268
277
|
case 5:
|
|
269
278
|
case "end":
|
|
@@ -298,10 +307,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
298
307
|
};
|
|
299
308
|
return _context3.abrupt("return", this.apiRequest.makeRequest({
|
|
300
309
|
uri: "".concat(url, "device"),
|
|
301
|
-
method:
|
|
310
|
+
method: _types3.HTTP_METHODS.POST,
|
|
302
311
|
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceInfo.clientDeviceUri), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
|
|
303
312
|
body: deviceInfo,
|
|
304
|
-
service:
|
|
313
|
+
service: _types3.ALLOWED_SERVICES.MOBIUS
|
|
305
314
|
}));
|
|
306
315
|
case 1:
|
|
307
316
|
case "end":
|
|
@@ -459,6 +468,67 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
459
468
|
}
|
|
460
469
|
return handle404KeepaliveFailure;
|
|
461
470
|
}()
|
|
471
|
+
/**
|
|
472
|
+
* Hard stops a calling session that Mobius reported as superseded, in response to a
|
|
473
|
+
* `409 Conflict` on a keepalive (device_status) message.
|
|
474
|
+
*
|
|
475
|
+
* Mobius returns 409 when this deviceId is gone but the same user still has an active
|
|
476
|
+
* registration elsewhere (typically calling opened in another browser tab, which
|
|
477
|
+
* superseded this device). Re-registering here would unregister the other device and
|
|
478
|
+
* restart the registration ping-pong between the two, so no registration is attempted:
|
|
479
|
+
* the keepalive worker is terminated, the Mobius WebSocket is closed and the consumer
|
|
480
|
+
* receives `LINE_EVENTS.UNREGISTERED` carrying `lineError` as the reason.
|
|
481
|
+
*
|
|
482
|
+
* @param lineError - Superseded-session error built by `handleRegistrationErrors`.
|
|
483
|
+
* @param error - The keepalive failure payload forwarded by the keepalive worker.
|
|
484
|
+
* @param serverType - Mobius server type the keepalive was sent to, for metrics.
|
|
485
|
+
* @param keepaliveRetryCount - Consecutive keepalive failures reported by the worker.
|
|
486
|
+
*/
|
|
487
|
+
)
|
|
488
|
+
}, {
|
|
489
|
+
key: "handle409KeepaliveFailure",
|
|
490
|
+
value: (function () {
|
|
491
|
+
var _handle409KeepaliveFailure = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7(lineError, error, serverType, keepaliveRetryCount) {
|
|
492
|
+
var _error$headers$tracki, _error$headers;
|
|
493
|
+
var loggerContext;
|
|
494
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
495
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
496
|
+
case 0:
|
|
497
|
+
loggerContext = {
|
|
498
|
+
file: _constants2.REGISTRATION_FILE,
|
|
499
|
+
method: _constants2.METHODS.HANDLE_409_KEEPALIVE_FAILURE
|
|
500
|
+
};
|
|
501
|
+
/*
|
|
502
|
+
* Latch the terminal state before anything that can yield. Cleanup runs under the
|
|
503
|
+
* shared mutex, so it can be queued behind a recovery that is already registering;
|
|
504
|
+
* latching here means every registration path that has not started yet sees the
|
|
505
|
+
* superseded state rather than racing this cleanup.
|
|
506
|
+
*/
|
|
507
|
+
this.sessionSuperseded = true;
|
|
508
|
+
_Logger.default.warn("Stopping keepalive without re-registration, session superseded by another device for this user - keepaliveRetryCount: ".concat(keepaliveRetryCount), loggerContext);
|
|
509
|
+
|
|
510
|
+
/* Stop the keepalive worker up front so no further keepalive is sent while cleanup waits on the mutex. */
|
|
511
|
+
this.clearKeepaliveTimer();
|
|
512
|
+
this.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.KEEPALIVE_ERROR, _types.REG_ACTION.KEEPALIVE_FAILURE, _types.METRIC_TYPE.BEHAVIORAL, _constants2.METHODS.HANDLE_409_KEEPALIVE_FAILURE, serverType, (_error$headers$tracki = (_error$headers = error.headers) === null || _error$headers === void 0 ? void 0 : _error$headers.trackingid) !== null && _error$headers$tracki !== void 0 ? _error$headers$tracki : '', keepaliveRetryCount, lineError);
|
|
513
|
+
_context7.next = 1;
|
|
514
|
+
return this.registrationCleanup(_constants2.METHODS.HANDLE_409_KEEPALIVE_FAILURE, {
|
|
515
|
+
reason: _types2.HARD_STOP_REASON.SESSION_SUPERSEDED,
|
|
516
|
+
error: lineError
|
|
517
|
+
});
|
|
518
|
+
case 1:
|
|
519
|
+
_context7.next = 2;
|
|
520
|
+
return (0, _common.uploadLogs)();
|
|
521
|
+
case 2:
|
|
522
|
+
case "end":
|
|
523
|
+
return _context7.stop();
|
|
524
|
+
}
|
|
525
|
+
}, _callee7, this);
|
|
526
|
+
}));
|
|
527
|
+
function handle409KeepaliveFailure(_x7, _x8, _x9, _x0) {
|
|
528
|
+
return _handle409KeepaliveFailure.apply(this, arguments);
|
|
529
|
+
}
|
|
530
|
+
return handle409KeepaliveFailure;
|
|
531
|
+
}()
|
|
462
532
|
/**
|
|
463
533
|
* Callback for handling 429 retry response from the server
|
|
464
534
|
*/
|
|
@@ -466,21 +536,21 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
466
536
|
}, {
|
|
467
537
|
key: "handle429Retry",
|
|
468
538
|
value: (function () {
|
|
469
|
-
var _handle429Retry = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
539
|
+
var _handle429Retry = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9(retryAfter, caller) {
|
|
470
540
|
var _this2 = this;
|
|
471
541
|
var interval, abort;
|
|
472
|
-
return _regenerator.default.wrap(function (
|
|
473
|
-
while (1) switch (
|
|
542
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
543
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
474
544
|
case 0:
|
|
475
545
|
if (!(caller === _constants2.FAILBACK_UTIL)) {
|
|
476
|
-
|
|
546
|
+
_context9.next = 4;
|
|
477
547
|
break;
|
|
478
548
|
}
|
|
479
549
|
if (!(this.failback429RetryAttempts >= _constants2.REG_FAILBACK_429_MAX_RETRIES)) {
|
|
480
|
-
|
|
550
|
+
_context9.next = 1;
|
|
481
551
|
break;
|
|
482
552
|
}
|
|
483
|
-
return
|
|
553
|
+
return _context9.abrupt("return");
|
|
484
554
|
case 1:
|
|
485
555
|
this.clearFailbackTimer();
|
|
486
556
|
this.failback429RetryAttempts += 1;
|
|
@@ -491,26 +561,26 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
491
561
|
interval = this.getRegRetryInterval(this.failback429RetryAttempts);
|
|
492
562
|
this.startFailbackTimer(interval);
|
|
493
563
|
this.scheduled429Retry = true;
|
|
494
|
-
|
|
564
|
+
_context9.next = 2;
|
|
495
565
|
return this.restorePreviousRegistration(_constants2.REG_429_RETRY_UTIL);
|
|
496
566
|
case 2:
|
|
497
|
-
abort =
|
|
567
|
+
abort = _context9.sent;
|
|
498
568
|
if (!(!abort && !this.isDeviceRegistered())) {
|
|
499
|
-
|
|
569
|
+
_context9.next = 3;
|
|
500
570
|
break;
|
|
501
571
|
}
|
|
502
|
-
|
|
572
|
+
_context9.next = 3;
|
|
503
573
|
return this.restartRegistration(_constants2.REG_429_RETRY_UTIL);
|
|
504
574
|
case 3:
|
|
505
|
-
|
|
575
|
+
_context9.next = 5;
|
|
506
576
|
break;
|
|
507
577
|
case 4:
|
|
508
578
|
if (caller === _constants2.KEEPALIVE_UTIL) {
|
|
509
579
|
this.clearKeepaliveTimer();
|
|
510
|
-
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
580
|
+
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
511
581
|
var _this2$deviceInfo$dev;
|
|
512
|
-
return _regenerator.default.wrap(function (
|
|
513
|
-
while (1) switch (
|
|
582
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
583
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
514
584
|
case 0:
|
|
515
585
|
_Logger.default.log("Resuming keepalive after ".concat(retryAfter, " seconds"), {
|
|
516
586
|
file: _constants2.REGISTRATION_FILE,
|
|
@@ -518,24 +588,24 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
518
588
|
});
|
|
519
589
|
|
|
520
590
|
// Resume the keepalive after waiting for the retry after period
|
|
521
|
-
|
|
591
|
+
_context8.next = 1;
|
|
522
592
|
return _this2.startKeepaliveTimer((_this2$deviceInfo$dev = _this2.deviceInfo.device) === null || _this2$deviceInfo$dev === void 0 ? void 0 : _this2$deviceInfo$dev.uri, _this2.deviceInfo.keepaliveInterval, 'UNKNOWN');
|
|
523
593
|
case 1:
|
|
524
594
|
case "end":
|
|
525
|
-
return
|
|
595
|
+
return _context8.stop();
|
|
526
596
|
}
|
|
527
|
-
},
|
|
597
|
+
}, _callee8);
|
|
528
598
|
})), (retryAfter - Number(this.deviceInfo.keepaliveInterval || 0)) * 1000);
|
|
529
599
|
} else {
|
|
530
600
|
this.retryAfter = retryAfter;
|
|
531
601
|
}
|
|
532
602
|
case 5:
|
|
533
603
|
case "end":
|
|
534
|
-
return
|
|
604
|
+
return _context9.stop();
|
|
535
605
|
}
|
|
536
|
-
},
|
|
606
|
+
}, _callee9, this);
|
|
537
607
|
}));
|
|
538
|
-
function handle429Retry(
|
|
608
|
+
function handle429Retry(_x1, _x10) {
|
|
539
609
|
return _handle429Retry.apply(this, arguments);
|
|
540
610
|
}
|
|
541
611
|
return handle429Retry;
|
|
@@ -564,7 +634,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
564
634
|
}, {
|
|
565
635
|
key: "startFailoverTimer",
|
|
566
636
|
value: (function () {
|
|
567
|
-
var _startFailoverTimer = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
637
|
+
var _startFailoverTimer = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
|
|
568
638
|
var _this3 = this;
|
|
569
639
|
var attempt,
|
|
570
640
|
timeElapsed,
|
|
@@ -574,12 +644,12 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
574
644
|
excessVal,
|
|
575
645
|
abort,
|
|
576
646
|
scheduledTime,
|
|
577
|
-
|
|
578
|
-
return _regenerator.default.wrap(function (
|
|
579
|
-
while (1) switch (
|
|
647
|
+
_args12 = arguments;
|
|
648
|
+
return _regenerator.default.wrap(function (_context12) {
|
|
649
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
580
650
|
case 0:
|
|
581
|
-
attempt =
|
|
582
|
-
timeElapsed =
|
|
651
|
+
attempt = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : 1;
|
|
652
|
+
timeElapsed = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : 0;
|
|
583
653
|
loggerContext = {
|
|
584
654
|
file: _constants2.REGISTRATION_FILE,
|
|
585
655
|
method: _constants2.FAILOVER_UTIL
|
|
@@ -594,7 +664,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
594
664
|
this.failoverImmediately = this.retryAfter + timeElapsed > TIMER_THRESHOLD;
|
|
595
665
|
}
|
|
596
666
|
if (!(interval > _constants2.BASE_REG_RETRY_TIMER_VAL_IN_SEC && !this.failoverImmediately)) {
|
|
597
|
-
|
|
667
|
+
_context12.next = 1;
|
|
598
668
|
break;
|
|
599
669
|
}
|
|
600
670
|
scheduledTime = Math.floor((0, _now.default)() / 1000);
|
|
@@ -607,53 +677,53 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
607
677
|
retryScheduledTime: scheduledTime,
|
|
608
678
|
serverType: 'primary'
|
|
609
679
|
});
|
|
610
|
-
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
611
|
-
return _regenerator.default.wrap(function (
|
|
612
|
-
while (1) switch (
|
|
680
|
+
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
|
|
681
|
+
return _regenerator.default.wrap(function (_context1) {
|
|
682
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
613
683
|
case 0:
|
|
614
|
-
|
|
615
|
-
return _this3.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
684
|
+
_context1.next = 1;
|
|
685
|
+
return _this3.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
|
|
616
686
|
var currentTime;
|
|
617
|
-
return _regenerator.default.wrap(function (
|
|
618
|
-
while (1) switch (
|
|
687
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
688
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
619
689
|
case 0:
|
|
620
|
-
|
|
690
|
+
_context0.next = 1;
|
|
621
691
|
return _this3.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL);
|
|
622
692
|
case 1:
|
|
623
|
-
abort =
|
|
693
|
+
abort = _context0.sent;
|
|
624
694
|
currentTime = Math.floor((0, _now.default)() / 1000);
|
|
625
695
|
if (!(!abort && !_this3.isDeviceRegistered())) {
|
|
626
|
-
|
|
696
|
+
_context0.next = 2;
|
|
627
697
|
break;
|
|
628
698
|
}
|
|
629
|
-
|
|
699
|
+
_context0.next = 2;
|
|
630
700
|
return _this3.startFailoverTimer(attempt + 1, timeElapsed + (currentTime - scheduledTime));
|
|
631
701
|
case 2:
|
|
632
702
|
case "end":
|
|
633
|
-
return
|
|
703
|
+
return _context0.stop();
|
|
634
704
|
}
|
|
635
|
-
},
|
|
705
|
+
}, _callee0);
|
|
636
706
|
})));
|
|
637
707
|
case 1:
|
|
638
708
|
case "end":
|
|
639
|
-
return
|
|
709
|
+
return _context1.stop();
|
|
640
710
|
}
|
|
641
|
-
},
|
|
711
|
+
}, _callee1);
|
|
642
712
|
})), interval * _constants2.SEC_TO_MSEC_MFACTOR);
|
|
643
713
|
_Logger.default.log("Scheduled retry with primary in ".concat(interval, " seconds, number of attempts : ").concat(attempt), loggerContext);
|
|
644
|
-
|
|
714
|
+
_context12.next = 7;
|
|
645
715
|
break;
|
|
646
716
|
case 1:
|
|
647
717
|
if (!this.backupMobiusUris.length) {
|
|
648
|
-
|
|
718
|
+
_context12.next = 5;
|
|
649
719
|
break;
|
|
650
720
|
}
|
|
651
721
|
if (!this.apiRequest.isSocketEnabled()) {
|
|
652
|
-
|
|
722
|
+
_context12.next = 3;
|
|
653
723
|
break;
|
|
654
724
|
}
|
|
655
725
|
_Logger.default.info('Disconnecting from primary Mobius socket for failover to backup servers', loggerContext);
|
|
656
|
-
|
|
726
|
+
_context12.next = 2;
|
|
657
727
|
return this.apiRequest.disconnectFromMobiusSocket({
|
|
658
728
|
code: 3050,
|
|
659
729
|
reason: 'done (permanent)'
|
|
@@ -669,66 +739,66 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
669
739
|
});
|
|
670
740
|
_Logger.default.info('Failing over to backup servers.', loggerContext);
|
|
671
741
|
this.failoverImmediately = false;
|
|
672
|
-
|
|
742
|
+
_context12.next = 4;
|
|
673
743
|
return this.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL, this.backupMobiusUris);
|
|
674
744
|
case 4:
|
|
675
|
-
abort =
|
|
745
|
+
abort = _context12.sent;
|
|
676
746
|
if (!abort && !this.isDeviceRegistered()) {
|
|
677
747
|
interval = this.getRegRetryInterval();
|
|
678
748
|
if (this.retryAfter != null && this.retryAfter < _constants2.RETRY_TIMER_UPPER_LIMIT) {
|
|
679
749
|
interval = interval < this.retryAfter ? this.retryAfter : interval;
|
|
680
750
|
}
|
|
681
|
-
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
682
|
-
return _regenerator.default.wrap(function (
|
|
683
|
-
while (1) switch (
|
|
751
|
+
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
|
752
|
+
return _regenerator.default.wrap(function (_context11) {
|
|
753
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
684
754
|
case 0:
|
|
685
|
-
|
|
686
|
-
return _this3.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
687
|
-
return _regenerator.default.wrap(function (
|
|
688
|
-
while (1) switch (
|
|
755
|
+
_context11.next = 1;
|
|
756
|
+
return _this3.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
|
757
|
+
return _regenerator.default.wrap(function (_context10) {
|
|
758
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
689
759
|
case 0:
|
|
690
|
-
|
|
760
|
+
_context10.next = 1;
|
|
691
761
|
return _this3.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL, _this3.backupMobiusUris);
|
|
692
762
|
case 1:
|
|
693
|
-
abort =
|
|
763
|
+
abort = _context10.sent;
|
|
694
764
|
if (!(!abort && !_this3.isDeviceRegistered())) {
|
|
695
|
-
|
|
765
|
+
_context10.next = 3;
|
|
696
766
|
break;
|
|
697
767
|
}
|
|
698
|
-
|
|
768
|
+
_context10.next = 2;
|
|
699
769
|
return (0, _common.uploadLogs)();
|
|
700
770
|
case 2:
|
|
701
771
|
(0, _common.emitFinalFailure)(function (clientError) {
|
|
702
|
-
_this3.lineEmitter(
|
|
772
|
+
_this3.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
|
|
703
773
|
}, loggerContext);
|
|
704
774
|
case 3:
|
|
705
775
|
case "end":
|
|
706
|
-
return
|
|
776
|
+
return _context10.stop();
|
|
707
777
|
}
|
|
708
|
-
},
|
|
778
|
+
}, _callee10);
|
|
709
779
|
})));
|
|
710
780
|
case 1:
|
|
711
781
|
case "end":
|
|
712
|
-
return
|
|
782
|
+
return _context11.stop();
|
|
713
783
|
}
|
|
714
|
-
},
|
|
784
|
+
}, _callee11);
|
|
715
785
|
})), interval * _constants2.SEC_TO_MSEC_MFACTOR);
|
|
716
786
|
_Logger.default.log("Scheduled retry with backup servers in ".concat(interval, " seconds."), loggerContext);
|
|
717
787
|
}
|
|
718
|
-
|
|
788
|
+
_context12.next = 7;
|
|
719
789
|
break;
|
|
720
790
|
case 5:
|
|
721
|
-
|
|
791
|
+
_context12.next = 6;
|
|
722
792
|
return (0, _common.uploadLogs)();
|
|
723
793
|
case 6:
|
|
724
794
|
(0, _common.emitFinalFailure)(function (clientError) {
|
|
725
|
-
_this3.lineEmitter(
|
|
795
|
+
_this3.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
|
|
726
796
|
}, loggerContext, interval < 0 ? 'Timer threshold exceeded during failover' : undefined);
|
|
727
797
|
case 7:
|
|
728
798
|
case "end":
|
|
729
|
-
return
|
|
799
|
+
return _context12.stop();
|
|
730
800
|
}
|
|
731
|
-
},
|
|
801
|
+
}, _callee12, this);
|
|
732
802
|
}));
|
|
733
803
|
function startFailoverTimer() {
|
|
734
804
|
return _startFailoverTimer.apply(this, arguments);
|
|
@@ -750,27 +820,27 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
750
820
|
}, {
|
|
751
821
|
key: "postKeepAlive",
|
|
752
822
|
value: function () {
|
|
753
|
-
var _postKeepAlive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
823
|
+
var _postKeepAlive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13(deviceUrl, url) {
|
|
754
824
|
var _this$deviceInfo$devi;
|
|
755
|
-
return _regenerator.default.wrap(function (
|
|
756
|
-
while (1) switch (
|
|
825
|
+
return _regenerator.default.wrap(function (_context13) {
|
|
826
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
757
827
|
case 0:
|
|
758
|
-
return
|
|
828
|
+
return _context13.abrupt("return", this.apiRequest.makeRequest({
|
|
759
829
|
uri: "".concat(url, "/status"),
|
|
760
|
-
method:
|
|
830
|
+
method: _types3.HTTP_METHODS.POST,
|
|
761
831
|
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, deviceUrl), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
|
|
762
832
|
body: {
|
|
763
833
|
deviceId: (_this$deviceInfo$devi = this.deviceInfo.device) === null || _this$deviceInfo$devi === void 0 ? void 0 : _this$deviceInfo$devi.deviceId
|
|
764
834
|
},
|
|
765
|
-
service:
|
|
835
|
+
service: _types3.ALLOWED_SERVICES.MOBIUS
|
|
766
836
|
}));
|
|
767
837
|
case 1:
|
|
768
838
|
case "end":
|
|
769
|
-
return
|
|
839
|
+
return _context13.stop();
|
|
770
840
|
}
|
|
771
|
-
},
|
|
841
|
+
}, _callee13, this);
|
|
772
842
|
}));
|
|
773
|
-
function postKeepAlive(
|
|
843
|
+
function postKeepAlive(_x11, _x12) {
|
|
774
844
|
return _postKeepAlive.apply(this, arguments);
|
|
775
845
|
}
|
|
776
846
|
return postKeepAlive;
|
|
@@ -778,34 +848,34 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
778
848
|
}, {
|
|
779
849
|
key: "isPrimaryActive",
|
|
780
850
|
value: function () {
|
|
781
|
-
var _isPrimaryActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
851
|
+
var _isPrimaryActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
|
|
782
852
|
var status, _iterator, _step, mobiusUrl, baseUri, response, _ref7, statusCode, _t3, _t4;
|
|
783
|
-
return _regenerator.default.wrap(function (
|
|
784
|
-
while (1) switch (
|
|
853
|
+
return _regenerator.default.wrap(function (_context14) {
|
|
854
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
785
855
|
case 0:
|
|
786
856
|
_iterator = _createForOfIteratorHelper(this.primaryMobiusUris);
|
|
787
|
-
|
|
857
|
+
_context14.prev = 1;
|
|
788
858
|
_iterator.s();
|
|
789
859
|
case 2:
|
|
790
860
|
if ((_step = _iterator.n()).done) {
|
|
791
|
-
|
|
861
|
+
_context14.next = 8;
|
|
792
862
|
break;
|
|
793
863
|
}
|
|
794
864
|
mobiusUrl = _step.value;
|
|
795
|
-
|
|
865
|
+
_context14.prev = 3;
|
|
796
866
|
baseUri = mobiusUrl.replace(_constants2.URL_ENDPOINT, '/').replace('wss://', 'https://'); // eslint-disable-next-line no-await-in-loop
|
|
797
|
-
|
|
867
|
+
_context14.next = 4;
|
|
798
868
|
return this.webex.request({
|
|
799
869
|
uri: "".concat(baseUri, "ping"),
|
|
800
|
-
method:
|
|
870
|
+
method: _types3.HTTP_METHODS.GET,
|
|
801
871
|
headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, this.webex.internal.device.url), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
|
|
802
|
-
service:
|
|
872
|
+
service: _types3.ALLOWED_SERVICES.MOBIUS
|
|
803
873
|
});
|
|
804
874
|
case 4:
|
|
805
|
-
response =
|
|
875
|
+
response = _context14.sent;
|
|
806
876
|
_ref7 = response, statusCode = _ref7.statusCode;
|
|
807
877
|
if (!(statusCode === 200)) {
|
|
808
|
-
|
|
878
|
+
_context14.next = 5;
|
|
809
879
|
break;
|
|
810
880
|
}
|
|
811
881
|
_Logger.default.info("Ping successful for primary Mobius: ".concat(mobiusUrl), {
|
|
@@ -813,39 +883,39 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
813
883
|
method: _constants2.FAILBACK_UTIL
|
|
814
884
|
});
|
|
815
885
|
status = 'up';
|
|
816
|
-
return
|
|
886
|
+
return _context14.abrupt("continue", 8);
|
|
817
887
|
case 5:
|
|
818
|
-
|
|
888
|
+
_context14.next = 7;
|
|
819
889
|
break;
|
|
820
890
|
case 6:
|
|
821
|
-
|
|
822
|
-
_t3 =
|
|
891
|
+
_context14.prev = 6;
|
|
892
|
+
_t3 = _context14["catch"](3);
|
|
823
893
|
_Logger.default.warn("Ping failed for primary Mobius: ".concat(mobiusUrl, " with error: ").concat((0, _stringify.default)(_t3)), {
|
|
824
894
|
file: _constants2.REGISTRATION_FILE,
|
|
825
895
|
method: _constants2.FAILBACK_UTIL
|
|
826
896
|
});
|
|
827
897
|
status = 'down';
|
|
828
898
|
case 7:
|
|
829
|
-
|
|
899
|
+
_context14.next = 2;
|
|
830
900
|
break;
|
|
831
901
|
case 8:
|
|
832
|
-
|
|
902
|
+
_context14.next = 10;
|
|
833
903
|
break;
|
|
834
904
|
case 9:
|
|
835
|
-
|
|
836
|
-
_t4 =
|
|
905
|
+
_context14.prev = 9;
|
|
906
|
+
_t4 = _context14["catch"](1);
|
|
837
907
|
_iterator.e(_t4);
|
|
838
908
|
case 10:
|
|
839
|
-
|
|
909
|
+
_context14.prev = 10;
|
|
840
910
|
_iterator.f();
|
|
841
|
-
return
|
|
911
|
+
return _context14.finish(10);
|
|
842
912
|
case 11:
|
|
843
|
-
return
|
|
913
|
+
return _context14.abrupt("return", status === 'up');
|
|
844
914
|
case 12:
|
|
845
915
|
case "end":
|
|
846
|
-
return
|
|
916
|
+
return _context14.stop();
|
|
847
917
|
}
|
|
848
|
-
},
|
|
918
|
+
}, _callee14, this, [[1, 9, 10, 11], [3, 6]]);
|
|
849
919
|
}));
|
|
850
920
|
function isPrimaryActive() {
|
|
851
921
|
return _isPrimaryActive.apply(this, arguments);
|
|
@@ -906,16 +976,16 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
906
976
|
key: "startFailbackTimer",
|
|
907
977
|
value: function startFailbackTimer(intervalInSeconds) {
|
|
908
978
|
var _this4 = this;
|
|
909
|
-
this.failbackTimer = setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
910
|
-
return _regenerator.default.wrap(function (
|
|
911
|
-
while (1) switch (
|
|
979
|
+
this.failbackTimer = setTimeout(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
980
|
+
return _regenerator.default.wrap(function (_context15) {
|
|
981
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
912
982
|
case 0:
|
|
913
|
-
return
|
|
983
|
+
return _context15.abrupt("return", _this4.executeFailback());
|
|
914
984
|
case 1:
|
|
915
985
|
case "end":
|
|
916
|
-
return
|
|
986
|
+
return _context15.stop();
|
|
917
987
|
}
|
|
918
|
-
},
|
|
988
|
+
}, _callee15);
|
|
919
989
|
})), intervalInSeconds * _constants2.SEC_TO_MSEC_MFACTOR);
|
|
920
990
|
_Logger.default.log("Failback scheduled after ".concat(intervalInSeconds, " seconds."), {
|
|
921
991
|
file: _constants2.REGISTRATION_FILE,
|
|
@@ -930,45 +1000,45 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
930
1000
|
}, {
|
|
931
1001
|
key: "executeFailback",
|
|
932
1002
|
value: (function () {
|
|
933
|
-
var _executeFailback = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1003
|
+
var _executeFailback = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
934
1004
|
var _this5 = this;
|
|
935
1005
|
var loggerContext;
|
|
936
|
-
return _regenerator.default.wrap(function (
|
|
937
|
-
while (1) switch (
|
|
1006
|
+
return _regenerator.default.wrap(function (_context17) {
|
|
1007
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
938
1008
|
case 0:
|
|
939
1009
|
loggerContext = {
|
|
940
1010
|
file: _constants2.REGISTRATION_FILE,
|
|
941
1011
|
method: _constants2.METHODS.EXECUTE_FAILBACK
|
|
942
1012
|
};
|
|
943
1013
|
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
944
|
-
|
|
945
|
-
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1014
|
+
_context17.next = 1;
|
|
1015
|
+
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
946
1016
|
var primaryServerStatus, abort, abortNew;
|
|
947
|
-
return _regenerator.default.wrap(function (
|
|
948
|
-
while (1) switch (
|
|
1017
|
+
return _regenerator.default.wrap(function (_context16) {
|
|
1018
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
949
1019
|
case 0:
|
|
950
1020
|
if (!_this5.isFailbackRequired()) {
|
|
951
|
-
|
|
1021
|
+
_context16.next = 13;
|
|
952
1022
|
break;
|
|
953
1023
|
}
|
|
954
|
-
|
|
1024
|
+
_context16.next = 1;
|
|
955
1025
|
return _this5.isPrimaryActive();
|
|
956
1026
|
case 1:
|
|
957
|
-
primaryServerStatus =
|
|
1027
|
+
primaryServerStatus = _context16.sent;
|
|
958
1028
|
if (!((0, _keys.default)(_this5.callManager.getActiveCalls()).length === 0 && primaryServerStatus)) {
|
|
959
|
-
|
|
1029
|
+
_context16.next = 12;
|
|
960
1030
|
break;
|
|
961
1031
|
}
|
|
962
1032
|
_Logger.default.info("Attempting failback to primary.", loggerContext);
|
|
963
|
-
|
|
1033
|
+
_context16.next = 2;
|
|
964
1034
|
return _this5.deregister();
|
|
965
1035
|
case 2:
|
|
966
1036
|
if (!_this5.apiRequest.isSocketEnabled()) {
|
|
967
|
-
|
|
1037
|
+
_context16.next = 4;
|
|
968
1038
|
break;
|
|
969
1039
|
}
|
|
970
1040
|
_Logger.default.info('Disconnecting from backup Mobius socket for failback to primary', loggerContext);
|
|
971
|
-
|
|
1041
|
+
_context16.next = 3;
|
|
972
1042
|
return _this5.apiRequest.disconnectFromMobiusSocket({
|
|
973
1043
|
code: 3050,
|
|
974
1044
|
reason: 'done (permanent)'
|
|
@@ -976,41 +1046,41 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
976
1046
|
case 3:
|
|
977
1047
|
_Logger.default.log('Mobius socket disconnect complete prior to primary failback', loggerContext);
|
|
978
1048
|
case 4:
|
|
979
|
-
|
|
1049
|
+
_context16.next = 5;
|
|
980
1050
|
return _this5.attemptRegistrationWithServers(_constants2.FAILBACK_UTIL);
|
|
981
1051
|
case 5:
|
|
982
|
-
abort =
|
|
1052
|
+
abort = _context16.sent;
|
|
983
1053
|
if (!(_this5.scheduled429Retry || abort || _this5.isDeviceRegistered())) {
|
|
984
|
-
|
|
1054
|
+
_context16.next = 6;
|
|
985
1055
|
break;
|
|
986
1056
|
}
|
|
987
|
-
return
|
|
1057
|
+
return _context16.abrupt("return");
|
|
988
1058
|
case 6:
|
|
989
|
-
|
|
1059
|
+
_context16.next = 7;
|
|
990
1060
|
return _this5.restorePreviousRegistration(_constants2.FAILBACK_UTIL);
|
|
991
1061
|
case 7:
|
|
992
|
-
abortNew =
|
|
1062
|
+
abortNew = _context16.sent;
|
|
993
1063
|
if (!abortNew) {
|
|
994
|
-
|
|
1064
|
+
_context16.next = 8;
|
|
995
1065
|
break;
|
|
996
1066
|
}
|
|
997
1067
|
_this5.clearFailbackTimer();
|
|
998
|
-
return
|
|
1068
|
+
return _context16.abrupt("return");
|
|
999
1069
|
case 8:
|
|
1000
1070
|
if (_this5.isDeviceRegistered()) {
|
|
1001
|
-
|
|
1071
|
+
_context16.next = 10;
|
|
1002
1072
|
break;
|
|
1003
1073
|
}
|
|
1004
|
-
|
|
1074
|
+
_context16.next = 9;
|
|
1005
1075
|
return _this5.restartRegistration(loggerContext.method);
|
|
1006
1076
|
case 9:
|
|
1007
|
-
|
|
1077
|
+
_context16.next = 11;
|
|
1008
1078
|
break;
|
|
1009
1079
|
case 10:
|
|
1010
1080
|
_this5.failbackTimer = undefined;
|
|
1011
1081
|
_this5.initiateFailback();
|
|
1012
1082
|
case 11:
|
|
1013
|
-
|
|
1083
|
+
_context16.next = 13;
|
|
1014
1084
|
break;
|
|
1015
1085
|
case 12:
|
|
1016
1086
|
_Logger.default.info('Active calls present or primary Mobius is down, deferring failback to next cycle.', loggerContext);
|
|
@@ -1018,15 +1088,15 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1018
1088
|
_this5.initiateFailback();
|
|
1019
1089
|
case 13:
|
|
1020
1090
|
case "end":
|
|
1021
|
-
return
|
|
1091
|
+
return _context16.stop();
|
|
1022
1092
|
}
|
|
1023
|
-
},
|
|
1093
|
+
}, _callee16);
|
|
1024
1094
|
})));
|
|
1025
1095
|
case 1:
|
|
1026
1096
|
case "end":
|
|
1027
|
-
return
|
|
1097
|
+
return _context17.stop();
|
|
1028
1098
|
}
|
|
1029
|
-
},
|
|
1099
|
+
}, _callee17, this);
|
|
1030
1100
|
}));
|
|
1031
1101
|
function executeFailback() {
|
|
1032
1102
|
return _executeFailback.apply(this, arguments);
|
|
@@ -1068,7 +1138,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1068
1138
|
}, {
|
|
1069
1139
|
key: "isDeviceRegistered",
|
|
1070
1140
|
value: function isDeviceRegistered() {
|
|
1071
|
-
return this.registrationStatus ===
|
|
1141
|
+
return this.registrationStatus === _types3.RegistrationStatus.ACTIVE;
|
|
1072
1142
|
}
|
|
1073
1143
|
}, {
|
|
1074
1144
|
key: "getStatus",
|
|
@@ -1089,10 +1159,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1089
1159
|
}, {
|
|
1090
1160
|
key: "restartRegistration",
|
|
1091
1161
|
value: (function () {
|
|
1092
|
-
var _restartRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1162
|
+
var _restartRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18(caller) {
|
|
1093
1163
|
var loggerContext, abort;
|
|
1094
|
-
return _regenerator.default.wrap(function (
|
|
1095
|
-
while (1) switch (
|
|
1164
|
+
return _regenerator.default.wrap(function (_context18) {
|
|
1165
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1096
1166
|
case 0:
|
|
1097
1167
|
loggerContext = {
|
|
1098
1168
|
file: _constants2.REGISTRATION_FILE,
|
|
@@ -1106,25 +1176,25 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1106
1176
|
*/
|
|
1107
1177
|
this.clearFailbackTimer();
|
|
1108
1178
|
this.failback429RetryAttempts = 0;
|
|
1109
|
-
|
|
1179
|
+
_context18.next = 1;
|
|
1110
1180
|
return this.attemptRegistrationWithServers(caller, this.primaryMobiusUris);
|
|
1111
1181
|
case 1:
|
|
1112
|
-
abort =
|
|
1182
|
+
abort = _context18.sent;
|
|
1113
1183
|
if (!(!abort && !this.isDeviceRegistered())) {
|
|
1114
|
-
|
|
1184
|
+
_context18.next = 2;
|
|
1115
1185
|
break;
|
|
1116
1186
|
}
|
|
1117
|
-
|
|
1187
|
+
_context18.next = 2;
|
|
1118
1188
|
return this.startFailoverTimer();
|
|
1119
1189
|
case 2:
|
|
1120
1190
|
_Logger.default.log("restartRegistration completed - caller: ".concat(caller, ", deviceRegistered: ").concat(this.isDeviceRegistered(), ", abort: ").concat(abort), loggerContext);
|
|
1121
1191
|
case 3:
|
|
1122
1192
|
case "end":
|
|
1123
|
-
return
|
|
1193
|
+
return _context18.stop();
|
|
1124
1194
|
}
|
|
1125
|
-
},
|
|
1195
|
+
}, _callee18, this);
|
|
1126
1196
|
}));
|
|
1127
|
-
function restartRegistration(
|
|
1197
|
+
function restartRegistration(_x13) {
|
|
1128
1198
|
return _restartRegistration.apply(this, arguments);
|
|
1129
1199
|
}
|
|
1130
1200
|
return restartRegistration;
|
|
@@ -1138,23 +1208,23 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1138
1208
|
}, {
|
|
1139
1209
|
key: "handleConnectionRestoration",
|
|
1140
1210
|
value: (function () {
|
|
1141
|
-
var _handleConnectionRestoration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1211
|
+
var _handleConnectionRestoration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20(retry) {
|
|
1142
1212
|
var _this6 = this;
|
|
1143
|
-
return _regenerator.default.wrap(function (
|
|
1144
|
-
while (1) switch (
|
|
1213
|
+
return _regenerator.default.wrap(function (_context20) {
|
|
1214
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1145
1215
|
case 0:
|
|
1146
1216
|
_Logger.default.info(_constants.METHOD_START_MESSAGE, {
|
|
1147
1217
|
method: _constants2.METHODS.HANDLE_CONNECTION_RESTORATION,
|
|
1148
1218
|
file: _constants2.REGISTRATION_FILE
|
|
1149
1219
|
});
|
|
1150
|
-
|
|
1151
|
-
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1220
|
+
_context20.next = 1;
|
|
1221
|
+
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
|
|
1152
1222
|
var abort;
|
|
1153
|
-
return _regenerator.default.wrap(function (
|
|
1154
|
-
while (1) switch (
|
|
1223
|
+
return _regenerator.default.wrap(function (_context19) {
|
|
1224
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1155
1225
|
case 0:
|
|
1156
1226
|
if (!retry) {
|
|
1157
|
-
|
|
1227
|
+
_context19.next = 4;
|
|
1158
1228
|
break;
|
|
1159
1229
|
}
|
|
1160
1230
|
_Logger.default.log('Network is up again, re-registering with Webex Calling if needed', {
|
|
@@ -1163,43 +1233,43 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1163
1233
|
});
|
|
1164
1234
|
_this6.clearKeepaliveTimer();
|
|
1165
1235
|
if (!_this6.isDeviceRegistered()) {
|
|
1166
|
-
|
|
1236
|
+
_context19.next = 1;
|
|
1167
1237
|
break;
|
|
1168
1238
|
}
|
|
1169
|
-
|
|
1239
|
+
_context19.next = 1;
|
|
1170
1240
|
return _this6.deregister();
|
|
1171
1241
|
case 1:
|
|
1172
1242
|
if (!_this6.activeMobiusUrl) {
|
|
1173
|
-
|
|
1243
|
+
_context19.next = 3;
|
|
1174
1244
|
break;
|
|
1175
1245
|
}
|
|
1176
|
-
|
|
1246
|
+
_context19.next = 2;
|
|
1177
1247
|
return _this6.restorePreviousRegistration(_constants2.METHODS.HANDLE_CONNECTION_RESTORATION);
|
|
1178
1248
|
case 2:
|
|
1179
|
-
abort =
|
|
1249
|
+
abort = _context19.sent;
|
|
1180
1250
|
if (!(!abort && !_this6.isDeviceRegistered())) {
|
|
1181
|
-
|
|
1251
|
+
_context19.next = 3;
|
|
1182
1252
|
break;
|
|
1183
1253
|
}
|
|
1184
|
-
|
|
1254
|
+
_context19.next = 3;
|
|
1185
1255
|
return _this6.restartRegistration(_constants2.METHODS.HANDLE_CONNECTION_RESTORATION);
|
|
1186
1256
|
case 3:
|
|
1187
1257
|
retry = false;
|
|
1188
1258
|
case 4:
|
|
1189
1259
|
case "end":
|
|
1190
|
-
return
|
|
1260
|
+
return _context19.stop();
|
|
1191
1261
|
}
|
|
1192
|
-
},
|
|
1262
|
+
}, _callee19);
|
|
1193
1263
|
})));
|
|
1194
1264
|
case 1:
|
|
1195
|
-
return
|
|
1265
|
+
return _context20.abrupt("return", retry);
|
|
1196
1266
|
case 2:
|
|
1197
1267
|
case "end":
|
|
1198
|
-
return
|
|
1268
|
+
return _context20.stop();
|
|
1199
1269
|
}
|
|
1200
|
-
},
|
|
1270
|
+
}, _callee20, this);
|
|
1201
1271
|
}));
|
|
1202
|
-
function handleConnectionRestoration(
|
|
1272
|
+
function handleConnectionRestoration(_x14) {
|
|
1203
1273
|
return _handleConnectionRestoration.apply(this, arguments);
|
|
1204
1274
|
}
|
|
1205
1275
|
return handleConnectionRestoration;
|
|
@@ -1215,53 +1285,53 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1215
1285
|
value: function restoreRegistrationCallBack() {
|
|
1216
1286
|
var _this7 = this;
|
|
1217
1287
|
return /*#__PURE__*/function () {
|
|
1218
|
-
var _ref1 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1288
|
+
var _ref1 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21(restoreData, caller) {
|
|
1219
1289
|
var logContext, restore, finalError;
|
|
1220
|
-
return _regenerator.default.wrap(function (
|
|
1221
|
-
while (1) switch (
|
|
1290
|
+
return _regenerator.default.wrap(function (_context21) {
|
|
1291
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1222
1292
|
case 0:
|
|
1223
1293
|
logContext = {
|
|
1224
1294
|
file: _constants2.REGISTRATION_FILE,
|
|
1225
1295
|
method: caller
|
|
1226
1296
|
};
|
|
1227
1297
|
if (_this7.isRegRetry()) {
|
|
1228
|
-
|
|
1298
|
+
_context21.next = 4;
|
|
1229
1299
|
break;
|
|
1230
1300
|
}
|
|
1231
1301
|
_Logger.default.info('Registration restoration in progress.', logContext);
|
|
1232
1302
|
restore = _this7.getExistingDevice(restoreData);
|
|
1233
1303
|
if (!restore) {
|
|
1234
|
-
|
|
1304
|
+
_context21.next = 3;
|
|
1235
1305
|
break;
|
|
1236
1306
|
}
|
|
1237
1307
|
_this7.setRegRetry(true);
|
|
1238
|
-
|
|
1308
|
+
_context21.next = 1;
|
|
1239
1309
|
return _this7.deregister();
|
|
1240
1310
|
case 1:
|
|
1241
|
-
|
|
1311
|
+
_context21.next = 2;
|
|
1242
1312
|
return _this7.restorePreviousRegistration(caller);
|
|
1243
1313
|
case 2:
|
|
1244
|
-
finalError =
|
|
1314
|
+
finalError = _context21.sent;
|
|
1245
1315
|
_this7.setRegRetry(false);
|
|
1246
1316
|
if (_this7.isDeviceRegistered()) {
|
|
1247
1317
|
_Logger.default.info('Registration restored successfully.', logContext);
|
|
1248
1318
|
}
|
|
1249
|
-
return
|
|
1319
|
+
return _context21.abrupt("return", finalError);
|
|
1250
1320
|
case 3:
|
|
1251
|
-
_this7.lineEmitter(
|
|
1252
|
-
|
|
1321
|
+
_this7.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1322
|
+
_context21.next = 5;
|
|
1253
1323
|
break;
|
|
1254
1324
|
case 4:
|
|
1255
|
-
_this7.lineEmitter(
|
|
1325
|
+
_this7.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1256
1326
|
case 5:
|
|
1257
|
-
return
|
|
1327
|
+
return _context21.abrupt("return", false);
|
|
1258
1328
|
case 6:
|
|
1259
1329
|
case "end":
|
|
1260
|
-
return
|
|
1330
|
+
return _context21.stop();
|
|
1261
1331
|
}
|
|
1262
|
-
},
|
|
1332
|
+
}, _callee21);
|
|
1263
1333
|
}));
|
|
1264
|
-
return function (
|
|
1334
|
+
return function (_x15, _x16) {
|
|
1265
1335
|
return _ref1.apply(this, arguments);
|
|
1266
1336
|
};
|
|
1267
1337
|
}();
|
|
@@ -1274,51 +1344,55 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1274
1344
|
}, {
|
|
1275
1345
|
key: "triggerRegistration",
|
|
1276
1346
|
value: (function () {
|
|
1277
|
-
var _triggerRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1347
|
+
var _triggerRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
|
|
1278
1348
|
var loggerContext, abort;
|
|
1279
|
-
return _regenerator.default.wrap(function (
|
|
1280
|
-
while (1) switch (
|
|
1349
|
+
return _regenerator.default.wrap(function (_context22) {
|
|
1350
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1281
1351
|
case 0:
|
|
1282
1352
|
loggerContext = {
|
|
1283
1353
|
file: _constants2.REGISTRATION_FILE,
|
|
1284
1354
|
method: _constants2.METHODS.TRIGGER_REGISTRATION
|
|
1285
1355
|
};
|
|
1286
1356
|
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
1287
|
-
|
|
1357
|
+
|
|
1358
|
+
/* An explicit registration from the consumer is the only way out of a superseded
|
|
1359
|
+
* session, so the terminal state is lifted here. */
|
|
1360
|
+
this.sessionSuperseded = false;
|
|
1361
|
+
_context22.next = 1;
|
|
1288
1362
|
return this.resumeFailover();
|
|
1289
1363
|
case 1:
|
|
1290
|
-
if (!
|
|
1291
|
-
|
|
1364
|
+
if (!_context22.sent) {
|
|
1365
|
+
_context22.next = 2;
|
|
1292
1366
|
break;
|
|
1293
1367
|
}
|
|
1294
1368
|
_Logger.default.info('Registration trigger handled by resumeFailover path', loggerContext);
|
|
1295
|
-
return
|
|
1369
|
+
return _context22.abrupt("return");
|
|
1296
1370
|
case 2:
|
|
1297
1371
|
if (!(this.primaryMobiusUris.length > 0)) {
|
|
1298
|
-
|
|
1372
|
+
_context22.next = 5;
|
|
1299
1373
|
break;
|
|
1300
1374
|
}
|
|
1301
|
-
|
|
1375
|
+
_context22.next = 3;
|
|
1302
1376
|
return this.attemptRegistrationWithServers(_constants2.REGISTRATION_UTIL, this.primaryMobiusUris);
|
|
1303
1377
|
case 3:
|
|
1304
|
-
abort =
|
|
1378
|
+
abort = _context22.sent;
|
|
1305
1379
|
if (!(!this.isDeviceRegistered() && !abort)) {
|
|
1306
|
-
|
|
1380
|
+
_context22.next = 4;
|
|
1307
1381
|
break;
|
|
1308
1382
|
}
|
|
1309
|
-
|
|
1383
|
+
_context22.next = 4;
|
|
1310
1384
|
return this.startFailoverTimer();
|
|
1311
1385
|
case 4:
|
|
1312
1386
|
_Logger.default.log("triggerRegistration completed - deviceRegistered: ".concat(this.isDeviceRegistered(), ", abort: ").concat(abort), loggerContext);
|
|
1313
|
-
|
|
1387
|
+
_context22.next = 6;
|
|
1314
1388
|
break;
|
|
1315
1389
|
case 5:
|
|
1316
1390
|
_Logger.default.warn('triggerRegistration skipped: no primary Mobius URIs available', loggerContext);
|
|
1317
1391
|
case 6:
|
|
1318
1392
|
case "end":
|
|
1319
|
-
return
|
|
1393
|
+
return _context22.stop();
|
|
1320
1394
|
}
|
|
1321
|
-
},
|
|
1395
|
+
}, _callee22, this);
|
|
1322
1396
|
}));
|
|
1323
1397
|
function triggerRegistration() {
|
|
1324
1398
|
return _triggerRegistration.apply(this, arguments);
|
|
@@ -1337,7 +1411,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1337
1411
|
}, {
|
|
1338
1412
|
key: "attemptRegistrationWithServers",
|
|
1339
1413
|
value: (function () {
|
|
1340
|
-
var _attemptRegistrationWithServers = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1414
|
+
var _attemptRegistrationWithServers = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23(caller) {
|
|
1341
1415
|
var _this8 = this;
|
|
1342
1416
|
var servers,
|
|
1343
1417
|
loggerContext,
|
|
@@ -1347,31 +1421,50 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1347
1421
|
_step2,
|
|
1348
1422
|
_loop,
|
|
1349
1423
|
_ret,
|
|
1350
|
-
|
|
1424
|
+
_args24 = arguments,
|
|
1351
1425
|
_t6;
|
|
1352
|
-
return _regenerator.default.wrap(function (
|
|
1353
|
-
while (1) switch (
|
|
1426
|
+
return _regenerator.default.wrap(function (_context24) {
|
|
1427
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1354
1428
|
case 0:
|
|
1355
|
-
servers =
|
|
1429
|
+
servers = _args24.length > 1 && _args24[1] !== undefined ? _args24[1] : this.primaryMobiusUris;
|
|
1356
1430
|
loggerContext = {
|
|
1357
1431
|
file: _constants2.REGISTRATION_FILE,
|
|
1358
1432
|
method: _constants2.REGISTER_UTIL
|
|
1359
1433
|
};
|
|
1434
|
+
/*
|
|
1435
|
+
* Single choke point for every registration attempt - initial registration, restore,
|
|
1436
|
+
* restart, the scheduled failover retries and failback all reach Mobius through here.
|
|
1437
|
+
* Guarding it once means a superseded session cannot be re-registered by any
|
|
1438
|
+
* automatic path, including one whose timer was already scheduled when the 409
|
|
1439
|
+
* arrived. `true` is returned so callers treat it as a final error and schedule no
|
|
1440
|
+
* further retries. `triggerRegistration()` clears the latch before calling in, so an
|
|
1441
|
+
* explicit registration by the consumer is unaffected.
|
|
1442
|
+
*/
|
|
1443
|
+
if (!this.sessionSuperseded) {
|
|
1444
|
+
_context24.next = 1;
|
|
1445
|
+
break;
|
|
1446
|
+
}
|
|
1447
|
+
_Logger.default.warn("Session superseded, skipping registration attempt - caller: ".concat(caller), {
|
|
1448
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1449
|
+
method: caller
|
|
1450
|
+
});
|
|
1451
|
+
return _context24.abrupt("return", true);
|
|
1452
|
+
case 1:
|
|
1360
1453
|
abort = false;
|
|
1361
1454
|
this.retryAfter = undefined;
|
|
1362
1455
|
if (!this.failoverImmediately) {
|
|
1363
|
-
|
|
1456
|
+
_context24.next = 2;
|
|
1364
1457
|
break;
|
|
1365
1458
|
}
|
|
1366
|
-
return
|
|
1367
|
-
case
|
|
1459
|
+
return _context24.abrupt("return", abort);
|
|
1460
|
+
case 2:
|
|
1368
1461
|
if (!this.isDeviceRegistered()) {
|
|
1369
|
-
|
|
1462
|
+
_context24.next = 3;
|
|
1370
1463
|
break;
|
|
1371
1464
|
}
|
|
1372
1465
|
_Logger.default.info("[".concat(caller, "] : Device already registered with : ").concat(this.activeMobiusUrl), loggerContext);
|
|
1373
|
-
return
|
|
1374
|
-
case
|
|
1466
|
+
return _context24.abrupt("return", abort);
|
|
1467
|
+
case 3:
|
|
1375
1468
|
/*
|
|
1376
1469
|
* Align the active transport with this server group. When the Mobius socket is enabled
|
|
1377
1470
|
* but a group has no WSS URL, CallingClient hands us its HTTP URIs instead; routing those
|
|
@@ -1383,90 +1476,93 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1383
1476
|
this.apiRequest.setSocketEnabled(servers[0].startsWith('wss://'));
|
|
1384
1477
|
}
|
|
1385
1478
|
_iterator2 = _createForOfIteratorHelper(servers);
|
|
1386
|
-
|
|
1479
|
+
_context24.prev = 4;
|
|
1387
1480
|
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
1388
1481
|
var url, serverType, _this8$deviceInfo$dev, _resp$headers, _resp$headers$trackin, _resp$headers2, _this8$deviceInfo$dev2, wssNormalizedUrl, resp, body, _yield$handleRegistra, finalError, shouldDisconnect, _t5;
|
|
1389
|
-
return _regenerator.default.wrap(function (
|
|
1390
|
-
while (1) switch (
|
|
1482
|
+
return _regenerator.default.wrap(function (_context23) {
|
|
1483
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1391
1484
|
case 0:
|
|
1392
1485
|
url = _step2.value;
|
|
1393
1486
|
serverType = _this8.getServerType(url);
|
|
1394
|
-
|
|
1487
|
+
_context23.prev = 1;
|
|
1395
1488
|
abort = false;
|
|
1396
|
-
_this8.registrationStatus =
|
|
1397
|
-
_this8.lineEmitter(
|
|
1489
|
+
_this8.registrationStatus = _types3.RegistrationStatus.INACTIVE;
|
|
1490
|
+
_this8.lineEmitter(_types4.LINE_EVENTS.CONNECTING);
|
|
1398
1491
|
_Logger.default.info("[".concat(caller, "] : Mobius url to contact: ").concat(url), loggerContext);
|
|
1399
1492
|
if (!_this8.apiRequest.isSocketEnabled()) {
|
|
1400
|
-
|
|
1493
|
+
_context23.next = 3;
|
|
1401
1494
|
break;
|
|
1402
1495
|
}
|
|
1403
1496
|
wssNormalizedUrl = url.endsWith('/') ? url.slice(0, -1) : url;
|
|
1404
1497
|
_Logger.default.info("[".concat(caller, "] : Connecting to Mobius WebSocket - serverType: ").concat(serverType, ", wssUrl: ").concat(wssNormalizedUrl), loggerContext);
|
|
1405
1498
|
|
|
1406
1499
|
// eslint-disable-next-line no-await-in-loop
|
|
1407
|
-
|
|
1500
|
+
_context23.next = 2;
|
|
1408
1501
|
return _this8.apiRequest.connectToMobiusSocket(wssNormalizedUrl);
|
|
1409
1502
|
case 2:
|
|
1410
|
-
connectedWebSocketUrl =
|
|
1503
|
+
connectedWebSocketUrl = _context23.sent;
|
|
1411
1504
|
connectedWebSocketUrl = connectedWebSocketUrl ? "".concat(connectedWebSocketUrl, "/") : undefined;
|
|
1412
1505
|
_Logger.default.log("[".concat(caller, "] : Mobius WebSocket connected - serverType: ").concat(serverType, ", connectedWebSocketUrl: ").concat(connectedWebSocketUrl), loggerContext);
|
|
1413
1506
|
case 3:
|
|
1414
|
-
|
|
1507
|
+
_context23.next = 4;
|
|
1415
1508
|
return _this8.postRegistration(url);
|
|
1416
1509
|
case 4:
|
|
1417
|
-
resp =
|
|
1510
|
+
resp = _context23.sent;
|
|
1418
1511
|
_this8.clearFailoverState();
|
|
1419
1512
|
_this8.deviceInfo = resp.body;
|
|
1420
|
-
_this8.registrationStatus =
|
|
1513
|
+
_this8.registrationStatus = _types3.RegistrationStatus.ACTIVE;
|
|
1421
1514
|
_this8.setActiveMobiusUrl(connectedWebSocketUrl || url);
|
|
1422
|
-
_this8.lineEmitter(
|
|
1515
|
+
_this8.lineEmitter(_types4.LINE_EVENTS.REGISTERED, resp.body);
|
|
1423
1516
|
_Logger.default.log("Registration successful for deviceId: ".concat((_this8$deviceInfo$dev = _this8.deviceInfo.device) === null || _this8$deviceInfo$dev === void 0 ? void 0 : _this8$deviceInfo$dev.deviceId, " userId: ").concat(_this8.userId, " responseTrackingId: ").concat((_resp$headers = resp.headers) === null || _resp$headers === void 0 ? void 0 : _resp$headers.trackingid), loggerContext);
|
|
1424
1517
|
_this8.setIntervalValues(_this8.deviceInfo);
|
|
1425
1518
|
_this8.metricManager.setDeviceInfo(_this8.deviceInfo);
|
|
1426
1519
|
_this8.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION, _types.REG_ACTION.REGISTER, _types.METRIC_TYPE.BEHAVIORAL, caller, serverType, (_resp$headers$trackin = (_resp$headers2 = resp.headers) === null || _resp$headers2 === void 0 ? void 0 : _resp$headers2.trackingid) !== null && _resp$headers$trackin !== void 0 ? _resp$headers$trackin : '', undefined, undefined);
|
|
1427
1520
|
_this8.startKeepaliveTimer((_this8$deviceInfo$dev2 = _this8.deviceInfo.device) === null || _this8$deviceInfo$dev2 === void 0 ? void 0 : _this8$deviceInfo$dev2.uri, _this8.deviceInfo.keepaliveInterval, serverType);
|
|
1428
1521
|
_this8.initiateFailback();
|
|
1429
|
-
return
|
|
1522
|
+
return _context23.abrupt("return", 0);
|
|
1430
1523
|
case 5:
|
|
1431
|
-
|
|
1432
|
-
_t5 =
|
|
1524
|
+
_context23.prev = 5;
|
|
1525
|
+
_t5 = _context23["catch"](1);
|
|
1433
1526
|
body = _t5; // eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unused-vars
|
|
1434
|
-
|
|
1527
|
+
_context23.next = 6;
|
|
1435
1528
|
return (0, _common.handleRegistrationErrors)(body, function (clientError, isFinalError) {
|
|
1436
1529
|
var _body$headers$trackin, _body$headers;
|
|
1437
1530
|
if (isFinalError) {
|
|
1438
|
-
_this8.lineEmitter(
|
|
1531
|
+
_this8.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
|
|
1439
1532
|
} else {
|
|
1440
|
-
_this8.lineEmitter(
|
|
1533
|
+
_this8.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1441
1534
|
}
|
|
1442
1535
|
_this8.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION_ERROR, _types.REG_ACTION.REGISTER, _types.METRIC_TYPE.BEHAVIORAL, caller, serverType, (_body$headers$trackin = (_body$headers = body.headers) === null || _body$headers === void 0 ? void 0 : _body$headers.trackingid) !== null && _body$headers$trackin !== void 0 ? _body$headers$trackin : '', undefined, clientError);
|
|
1443
1536
|
}, {
|
|
1444
1537
|
method: caller,
|
|
1445
1538
|
file: _constants2.REGISTRATION_FILE
|
|
1446
|
-
},
|
|
1447
|
-
|
|
1448
|
-
|
|
1539
|
+
}, {
|
|
1540
|
+
retry429Cb: function retry429Cb(retryAfter, retryCaller) {
|
|
1541
|
+
return _this8.handle429Retry(retryAfter, retryCaller);
|
|
1542
|
+
},
|
|
1543
|
+
restoreRegCb: _this8.restoreRegistrationCallBack()
|
|
1544
|
+
}, servers.length);
|
|
1449
1545
|
case 6:
|
|
1450
|
-
_yield$handleRegistra =
|
|
1546
|
+
_yield$handleRegistra = _context23.sent;
|
|
1451
1547
|
finalError = _yield$handleRegistra.finalError;
|
|
1452
1548
|
shouldDisconnect = _yield$handleRegistra.shouldDisconnect;
|
|
1453
1549
|
abort = finalError;
|
|
1454
|
-
if (!(_this8.registrationStatus ===
|
|
1455
|
-
|
|
1550
|
+
if (!(_this8.registrationStatus === _types3.RegistrationStatus.ACTIVE)) {
|
|
1551
|
+
_context23.next = 7;
|
|
1456
1552
|
break;
|
|
1457
1553
|
}
|
|
1458
1554
|
_Logger.default.info("[".concat(caller, "] : Device is already restored, active mobius url: ").concat(_this8.activeMobiusUrl), loggerContext);
|
|
1459
|
-
return
|
|
1555
|
+
return _context23.abrupt("return", 0);
|
|
1460
1556
|
case 7:
|
|
1461
1557
|
if (!(shouldDisconnect && _this8.apiRequest.isSocketEnabled())) {
|
|
1462
|
-
|
|
1558
|
+
_context23.next = 9;
|
|
1463
1559
|
break;
|
|
1464
1560
|
}
|
|
1465
1561
|
connectedWebSocketUrl = undefined;
|
|
1466
1562
|
_Logger.default.info("[".concat(caller, "] : Tearing down Mobius WebSocket after registration error - serverType: ").concat(serverType), loggerContext);
|
|
1467
1563
|
|
|
1468
1564
|
// eslint-disable-next-line no-await-in-loop
|
|
1469
|
-
|
|
1565
|
+
_context23.next = 8;
|
|
1470
1566
|
return _this8.apiRequest.disconnectFromMobiusSocket({
|
|
1471
1567
|
code: 3050,
|
|
1472
1568
|
reason: 'done (permanent)'
|
|
@@ -1475,58 +1571,58 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1475
1571
|
_Logger.default.log("[".concat(caller, "] : Mobius WebSocket disconnect complete after registration error - serverType: ").concat(serverType), loggerContext);
|
|
1476
1572
|
case 9:
|
|
1477
1573
|
if (!abort) {
|
|
1478
|
-
|
|
1574
|
+
_context23.next = 11;
|
|
1479
1575
|
break;
|
|
1480
1576
|
}
|
|
1481
|
-
_this8.setStatus(
|
|
1577
|
+
_this8.setStatus(_types3.RegistrationStatus.INACTIVE);
|
|
1482
1578
|
// eslint-disable-next-line no-await-in-loop
|
|
1483
|
-
|
|
1579
|
+
_context23.next = 10;
|
|
1484
1580
|
return (0, _common.uploadLogs)();
|
|
1485
1581
|
case 10:
|
|
1486
|
-
return
|
|
1582
|
+
return _context23.abrupt("return", 0);
|
|
1487
1583
|
case 11:
|
|
1488
1584
|
case "end":
|
|
1489
|
-
return
|
|
1585
|
+
return _context23.stop();
|
|
1490
1586
|
}
|
|
1491
1587
|
}, _loop, null, [[1, 5]]);
|
|
1492
1588
|
});
|
|
1493
1589
|
_iterator2.s();
|
|
1494
|
-
case
|
|
1590
|
+
case 5:
|
|
1495
1591
|
if ((_step2 = _iterator2.n()).done) {
|
|
1496
|
-
|
|
1592
|
+
_context24.next = 8;
|
|
1497
1593
|
break;
|
|
1498
1594
|
}
|
|
1499
|
-
return
|
|
1500
|
-
case
|
|
1501
|
-
_ret =
|
|
1595
|
+
return _context24.delegateYield(_loop(), "t0", 6);
|
|
1596
|
+
case 6:
|
|
1597
|
+
_ret = _context24.t0;
|
|
1502
1598
|
if (!(_ret === 0)) {
|
|
1503
|
-
|
|
1599
|
+
_context24.next = 7;
|
|
1504
1600
|
break;
|
|
1505
1601
|
}
|
|
1506
|
-
return
|
|
1507
|
-
case 6:
|
|
1508
|
-
_context23.next = 4;
|
|
1509
|
-
break;
|
|
1602
|
+
return _context24.abrupt("continue", 8);
|
|
1510
1603
|
case 7:
|
|
1511
|
-
|
|
1604
|
+
_context24.next = 5;
|
|
1512
1605
|
break;
|
|
1513
1606
|
case 8:
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
_iterator2.e(_t6);
|
|
1607
|
+
_context24.next = 10;
|
|
1608
|
+
break;
|
|
1517
1609
|
case 9:
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1610
|
+
_context24.prev = 9;
|
|
1611
|
+
_t6 = _context24["catch"](4);
|
|
1612
|
+
_iterator2.e(_t6);
|
|
1521
1613
|
case 10:
|
|
1522
|
-
|
|
1614
|
+
_context24.prev = 10;
|
|
1615
|
+
_iterator2.f();
|
|
1616
|
+
return _context24.finish(10);
|
|
1523
1617
|
case 11:
|
|
1618
|
+
return _context24.abrupt("return", abort);
|
|
1619
|
+
case 12:
|
|
1524
1620
|
case "end":
|
|
1525
|
-
return
|
|
1621
|
+
return _context24.stop();
|
|
1526
1622
|
}
|
|
1527
|
-
},
|
|
1623
|
+
}, _callee23, this, [[4, 9, 10, 11]]);
|
|
1528
1624
|
}));
|
|
1529
|
-
function attemptRegistrationWithServers(
|
|
1625
|
+
function attemptRegistrationWithServers(_x17) {
|
|
1530
1626
|
return _attemptRegistrationWithServers.apply(this, arguments);
|
|
1531
1627
|
}
|
|
1532
1628
|
return attemptRegistrationWithServers;
|
|
@@ -1539,19 +1635,19 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1539
1635
|
}, {
|
|
1540
1636
|
key: "startKeepaliveTimer",
|
|
1541
1637
|
value: (function () {
|
|
1542
|
-
var _startKeepaliveTimer = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1638
|
+
var _startKeepaliveTimer = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26(url, interval, serverType) {
|
|
1543
1639
|
var _this9 = this;
|
|
1544
1640
|
var RETRY_COUNT_THRESHOLD;
|
|
1545
|
-
return _regenerator.default.wrap(function (
|
|
1546
|
-
while (1) switch (
|
|
1641
|
+
return _regenerator.default.wrap(function (_context27) {
|
|
1642
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1547
1643
|
case 0:
|
|
1548
1644
|
this.clearKeepaliveTimer();
|
|
1549
1645
|
RETRY_COUNT_THRESHOLD = this.isCCFlow ? 4 : 5;
|
|
1550
|
-
|
|
1551
|
-
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1552
|
-
var blob, blobUrl;
|
|
1553
|
-
return _regenerator.default.wrap(function (
|
|
1554
|
-
while (1) switch (
|
|
1646
|
+
_context27.next = 1;
|
|
1647
|
+
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
|
|
1648
|
+
var blob, blobUrl, worker, isCurrentWorker;
|
|
1649
|
+
return _regenerator.default.wrap(function (_context26) {
|
|
1650
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1555
1651
|
case 0:
|
|
1556
1652
|
if (_this9.isDeviceRegistered()) {
|
|
1557
1653
|
if (!_this9.webWorker) {
|
|
@@ -1559,41 +1655,67 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1559
1655
|
type: 'application/javascript'
|
|
1560
1656
|
});
|
|
1561
1657
|
blobUrl = URL.createObjectURL(blob);
|
|
1562
|
-
|
|
1658
|
+
worker = new Worker(blobUrl);
|
|
1659
|
+
_this9.webWorker = worker;
|
|
1563
1660
|
URL.revokeObjectURL(blobUrl);
|
|
1564
|
-
|
|
1565
|
-
type:
|
|
1661
|
+
worker.postMessage({
|
|
1662
|
+
type: _types3.WorkerMessageType.START_KEEPALIVE,
|
|
1566
1663
|
interval: interval,
|
|
1567
1664
|
retryCountThreshold: RETRY_COUNT_THRESHOLD
|
|
1568
1665
|
});
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1666
|
+
|
|
1667
|
+
/*
|
|
1668
|
+
* A keepalive is in flight across an `await`, so this worker can be replaced
|
|
1669
|
+
* meanwhile - on failback, connection restoration or any re-registration. Its
|
|
1670
|
+
* result then belongs to a device that is no longer the registered one and must
|
|
1671
|
+
* not reach the current worker, whose retry count and failure handling (including
|
|
1672
|
+
* the 409 hard stop) would otherwise act on a stale registration.
|
|
1673
|
+
*/
|
|
1674
|
+
isCurrentWorker = function isCurrentWorker() {
|
|
1675
|
+
return _this9.webWorker === worker;
|
|
1676
|
+
};
|
|
1677
|
+
worker.onmessage = /*#__PURE__*/function () {
|
|
1678
|
+
var _ref11 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24(event) {
|
|
1679
|
+
var logContext, res, _err$headers, error, _error, _yield$handleRegistra2, abort, _t7;
|
|
1680
|
+
return _regenerator.default.wrap(function (_context25) {
|
|
1681
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1574
1682
|
case 0:
|
|
1575
1683
|
logContext = {
|
|
1576
1684
|
file: _constants2.REGISTRATION_FILE,
|
|
1577
1685
|
method: _constants2.KEEPALIVE_UTIL
|
|
1578
1686
|
};
|
|
1579
|
-
if (
|
|
1580
|
-
|
|
1687
|
+
if (isCurrentWorker()) {
|
|
1688
|
+
_context25.next = 1;
|
|
1689
|
+
break;
|
|
1690
|
+
}
|
|
1691
|
+
_Logger.default.info('Ignoring message from a replaced keepalive worker', logContext);
|
|
1692
|
+
return _context25.abrupt("return");
|
|
1693
|
+
case 1:
|
|
1694
|
+
if (!(event.data.type === _types3.WorkerMessageType.SEND_KEEPALIVE)) {
|
|
1695
|
+
_context25.next = 7;
|
|
1581
1696
|
break;
|
|
1582
1697
|
}
|
|
1583
|
-
|
|
1584
|
-
|
|
1698
|
+
_context25.prev = 2;
|
|
1699
|
+
_context25.next = 3;
|
|
1585
1700
|
return _this9.postKeepAlive(String(_this9.webex.internal.device.url), url);
|
|
1586
|
-
case
|
|
1587
|
-
res =
|
|
1588
|
-
(
|
|
1589
|
-
|
|
1701
|
+
case 3:
|
|
1702
|
+
res = _context25.sent;
|
|
1703
|
+
if (isCurrentWorker()) {
|
|
1704
|
+
_context25.next = 4;
|
|
1705
|
+
break;
|
|
1706
|
+
}
|
|
1707
|
+
_Logger.default.info('Discarding keepalive result of a replaced worker', logContext);
|
|
1708
|
+
return _context25.abrupt("return");
|
|
1709
|
+
case 4:
|
|
1710
|
+
worker.postMessage({
|
|
1711
|
+
type: _types3.WorkerMessageType.KEEPALIVE_RESULT,
|
|
1590
1712
|
statusCode: res.statusCode
|
|
1591
1713
|
});
|
|
1592
|
-
|
|
1714
|
+
_context25.next = 7;
|
|
1593
1715
|
break;
|
|
1594
|
-
case
|
|
1595
|
-
|
|
1596
|
-
_t7 =
|
|
1716
|
+
case 5:
|
|
1717
|
+
_context25.prev = 5;
|
|
1718
|
+
_t7 = _context25["catch"](2);
|
|
1597
1719
|
error = {
|
|
1598
1720
|
headers: {
|
|
1599
1721
|
trackingid: (_err$headers = _t7.headers) === null || _err$headers === void 0 ? void 0 : _err$headers.trackingid,
|
|
@@ -1603,74 +1725,92 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1603
1725
|
statusText: _t7.statusText,
|
|
1604
1726
|
type: _t7.type
|
|
1605
1727
|
};
|
|
1606
|
-
(
|
|
1607
|
-
|
|
1728
|
+
if (isCurrentWorker()) {
|
|
1729
|
+
_context25.next = 6;
|
|
1730
|
+
break;
|
|
1731
|
+
}
|
|
1732
|
+
_Logger.default.info("Discarding keepalive failure of a replaced worker, status -> ".concat(error.statusCode), logContext);
|
|
1733
|
+
return _context25.abrupt("return");
|
|
1734
|
+
case 6:
|
|
1735
|
+
worker.postMessage({
|
|
1736
|
+
type: _types3.WorkerMessageType.KEEPALIVE_RESULT,
|
|
1608
1737
|
err: error
|
|
1609
1738
|
});
|
|
1610
|
-
case
|
|
1611
|
-
if (event.data.type ===
|
|
1739
|
+
case 7:
|
|
1740
|
+
if (event.data.type === _types3.WorkerMessageType.KEEPALIVE_SUCCESS) {
|
|
1612
1741
|
_Logger.default.info("Sent Keepalive, status: ".concat(event.data.statusCode), logContext);
|
|
1613
|
-
_this9.lineEmitter(
|
|
1742
|
+
_this9.lineEmitter(_types4.LINE_EVENTS.RECONNECTED);
|
|
1614
1743
|
}
|
|
1615
|
-
if (!(event.data.type ===
|
|
1616
|
-
|
|
1744
|
+
if (!(event.data.type === _types3.WorkerMessageType.KEEPALIVE_FAILURE)) {
|
|
1745
|
+
_context25.next = 15;
|
|
1617
1746
|
break;
|
|
1618
1747
|
}
|
|
1619
1748
|
_error = event.data.err;
|
|
1620
1749
|
_Logger.default.warn("Keep-alive missed ".concat(event.data.keepAliveRetryCount, " times. Status -> ").concat(_error.statusCode, " "), logContext);
|
|
1621
|
-
|
|
1750
|
+
_context25.next = 8;
|
|
1622
1751
|
return (0, _common.handleRegistrationErrors)(_error, function (clientError, finalError) {
|
|
1623
|
-
var _error$headers$
|
|
1752
|
+
var _error$headers$tracki2, _error$headers2;
|
|
1624
1753
|
if (finalError) {
|
|
1625
|
-
_this9.lineEmitter(
|
|
1754
|
+
_this9.lineEmitter(_types4.LINE_EVENTS.ERROR, undefined, clientError);
|
|
1626
1755
|
}
|
|
1627
|
-
_this9.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.KEEPALIVE_ERROR, _types.REG_ACTION.KEEPALIVE_FAILURE, _types.METRIC_TYPE.BEHAVIORAL, _constants2.KEEPALIVE_UTIL, serverType, (_error$headers$
|
|
1756
|
+
_this9.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.KEEPALIVE_ERROR, _types.REG_ACTION.KEEPALIVE_FAILURE, _types.METRIC_TYPE.BEHAVIORAL, _constants2.KEEPALIVE_UTIL, serverType, (_error$headers$tracki2 = (_error$headers2 = _error.headers) === null || _error$headers2 === void 0 ? void 0 : _error$headers2.trackingid) !== null && _error$headers$tracki2 !== void 0 ? _error$headers$tracki2 : '', event.data.keepAliveRetryCount, clientError);
|
|
1628
1757
|
}, {
|
|
1629
1758
|
method: _constants2.KEEPALIVE_UTIL,
|
|
1630
1759
|
file: _constants2.REGISTRATION_FILE
|
|
1631
|
-
},
|
|
1632
|
-
|
|
1760
|
+
}, {
|
|
1761
|
+
retry429Cb: function retry429Cb(retryAfter, retryCaller) {
|
|
1762
|
+
return _this9.handle429Retry(retryAfter, retryCaller);
|
|
1763
|
+
},
|
|
1764
|
+
sessionSupersededCb: function sessionSupersededCb(clientError) {
|
|
1765
|
+
return _this9.handle409KeepaliveFailure(clientError, _error, serverType, event.data.keepAliveRetryCount);
|
|
1766
|
+
}
|
|
1633
1767
|
});
|
|
1634
|
-
case
|
|
1635
|
-
_yield$handleRegistra2 =
|
|
1768
|
+
case 8:
|
|
1769
|
+
_yield$handleRegistra2 = _context25.sent;
|
|
1636
1770
|
abort = _yield$handleRegistra2.finalError;
|
|
1771
|
+
if (!(abort && Number(_error.statusCode) === _types5.ERROR_CODE.CONFLICT)) {
|
|
1772
|
+
_context25.next = 9;
|
|
1773
|
+
break;
|
|
1774
|
+
}
|
|
1775
|
+
return _context25.abrupt("return");
|
|
1776
|
+
case 9:
|
|
1637
1777
|
if (!(abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD)) {
|
|
1638
|
-
|
|
1778
|
+
_context25.next = 14;
|
|
1639
1779
|
break;
|
|
1640
1780
|
}
|
|
1641
1781
|
_this9.failoverImmediately = _this9.isCCFlow;
|
|
1642
|
-
_this9.setStatus(
|
|
1782
|
+
_this9.setStatus(_types3.RegistrationStatus.INACTIVE);
|
|
1643
1783
|
_this9.clearKeepaliveTimer();
|
|
1644
1784
|
_this9.clearFailbackTimer();
|
|
1645
|
-
_this9.lineEmitter(
|
|
1646
|
-
|
|
1785
|
+
_this9.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED);
|
|
1786
|
+
_context25.next = 10;
|
|
1647
1787
|
return (0, _common.uploadLogs)();
|
|
1648
|
-
case
|
|
1788
|
+
case 10:
|
|
1649
1789
|
if (abort) {
|
|
1650
|
-
|
|
1790
|
+
_context25.next = 12;
|
|
1651
1791
|
break;
|
|
1652
1792
|
}
|
|
1653
|
-
|
|
1793
|
+
_context25.next = 11;
|
|
1654
1794
|
return _this9.reconnectOnFailure(_constants2.RECONNECT_ON_FAILURE_UTIL);
|
|
1655
|
-
case
|
|
1656
|
-
|
|
1795
|
+
case 11:
|
|
1796
|
+
_context25.next = 13;
|
|
1657
1797
|
break;
|
|
1658
|
-
case
|
|
1798
|
+
case 12:
|
|
1659
1799
|
if (_error.statusCode === 404) {
|
|
1660
1800
|
_this9.handle404KeepaliveFailure(_constants2.KEEPALIVE_UTIL);
|
|
1661
1801
|
}
|
|
1662
|
-
case
|
|
1663
|
-
|
|
1802
|
+
case 13:
|
|
1803
|
+
_context25.next = 15;
|
|
1664
1804
|
break;
|
|
1665
|
-
case
|
|
1666
|
-
_this9.lineEmitter(
|
|
1667
|
-
case
|
|
1805
|
+
case 14:
|
|
1806
|
+
_this9.lineEmitter(_types4.LINE_EVENTS.RECONNECTING);
|
|
1807
|
+
case 15:
|
|
1668
1808
|
case "end":
|
|
1669
|
-
return
|
|
1809
|
+
return _context25.stop();
|
|
1670
1810
|
}
|
|
1671
|
-
},
|
|
1811
|
+
}, _callee24, null, [[2, 5]]);
|
|
1672
1812
|
}));
|
|
1673
|
-
return function (
|
|
1813
|
+
return function (_x21) {
|
|
1674
1814
|
return _ref11.apply(this, arguments);
|
|
1675
1815
|
};
|
|
1676
1816
|
}();
|
|
@@ -1678,17 +1818,17 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1678
1818
|
}
|
|
1679
1819
|
case 1:
|
|
1680
1820
|
case "end":
|
|
1681
|
-
return
|
|
1821
|
+
return _context26.stop();
|
|
1682
1822
|
}
|
|
1683
|
-
},
|
|
1823
|
+
}, _callee25);
|
|
1684
1824
|
})));
|
|
1685
1825
|
case 1:
|
|
1686
1826
|
case "end":
|
|
1687
|
-
return
|
|
1827
|
+
return _context27.stop();
|
|
1688
1828
|
}
|
|
1689
|
-
},
|
|
1829
|
+
}, _callee26, this);
|
|
1690
1830
|
}));
|
|
1691
|
-
function startKeepaliveTimer(
|
|
1831
|
+
function startKeepaliveTimer(_x18, _x19, _x20) {
|
|
1692
1832
|
return _startKeepaliveTimer.apply(this, arguments);
|
|
1693
1833
|
}
|
|
1694
1834
|
return startKeepaliveTimer;
|
|
@@ -1702,7 +1842,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1702
1842
|
value: function clearKeepaliveTimer() {
|
|
1703
1843
|
if (this.webWorker) {
|
|
1704
1844
|
this.webWorker.postMessage({
|
|
1705
|
-
type:
|
|
1845
|
+
type: _types3.WorkerMessageType.CLEAR_KEEPALIVE
|
|
1706
1846
|
});
|
|
1707
1847
|
this.webWorker.terminate();
|
|
1708
1848
|
this.webWorker = undefined;
|
|
@@ -1716,39 +1856,39 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1716
1856
|
}, {
|
|
1717
1857
|
key: "deregister",
|
|
1718
1858
|
value: function () {
|
|
1719
|
-
var _deregister = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1859
|
+
var _deregister = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
|
|
1720
1860
|
var closeMobiusWss,
|
|
1721
1861
|
loggerContext,
|
|
1722
1862
|
_this$deviceInfo$devi2,
|
|
1723
1863
|
_this$deviceInfo$devi3,
|
|
1724
|
-
|
|
1864
|
+
_args28 = arguments,
|
|
1725
1865
|
_t8;
|
|
1726
|
-
return _regenerator.default.wrap(function (
|
|
1727
|
-
while (1) switch (
|
|
1866
|
+
return _regenerator.default.wrap(function (_context28) {
|
|
1867
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1728
1868
|
case 0:
|
|
1729
|
-
closeMobiusWss =
|
|
1869
|
+
closeMobiusWss = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : false;
|
|
1730
1870
|
loggerContext = {
|
|
1731
1871
|
file: _constants2.REGISTRATION_FILE,
|
|
1732
1872
|
method: _constants2.METHODS.DEREGISTER
|
|
1733
1873
|
};
|
|
1734
1874
|
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
1735
|
-
|
|
1736
|
-
|
|
1875
|
+
_context28.prev = 1;
|
|
1876
|
+
_context28.next = 2;
|
|
1737
1877
|
return this.deleteRegistration(this.activeMobiusUrl, (_this$deviceInfo$devi2 = this.deviceInfo.device) === null || _this$deviceInfo$devi2 === void 0 ? void 0 : _this$deviceInfo$devi2.deviceId, (_this$deviceInfo$devi3 = this.deviceInfo.device) === null || _this$deviceInfo$devi3 === void 0 ? void 0 : _this$deviceInfo$devi3.clientDeviceUri);
|
|
1738
1878
|
case 2:
|
|
1739
1879
|
_Logger.default.log('Registration successfully deregistered', loggerContext);
|
|
1740
|
-
|
|
1880
|
+
_context28.next = 4;
|
|
1741
1881
|
break;
|
|
1742
1882
|
case 3:
|
|
1743
|
-
|
|
1744
|
-
_t8 =
|
|
1883
|
+
_context28.prev = 3;
|
|
1884
|
+
_t8 = _context28["catch"](1);
|
|
1745
1885
|
_Logger.default.warn("Delete failed with Mobius: ".concat((0, _stringify.default)(_t8)), loggerContext);
|
|
1746
1886
|
case 4:
|
|
1747
1887
|
if (!closeMobiusWss) {
|
|
1748
|
-
|
|
1888
|
+
_context28.next = 6;
|
|
1749
1889
|
break;
|
|
1750
1890
|
}
|
|
1751
|
-
|
|
1891
|
+
_context28.next = 5;
|
|
1752
1892
|
return this.apiRequest.disconnectFromMobiusSocket({
|
|
1753
1893
|
code: 3050,
|
|
1754
1894
|
reason: 'done (permanent)'
|
|
@@ -1757,13 +1897,13 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1757
1897
|
_Logger.default.log('Mobius socket disconnect complete after deregistration', loggerContext);
|
|
1758
1898
|
case 6:
|
|
1759
1899
|
this.clearKeepaliveTimer();
|
|
1760
|
-
this.setStatus(
|
|
1900
|
+
this.setStatus(_types3.RegistrationStatus.INACTIVE);
|
|
1761
1901
|
this.clearFailoverState();
|
|
1762
1902
|
case 7:
|
|
1763
1903
|
case "end":
|
|
1764
|
-
return
|
|
1904
|
+
return _context28.stop();
|
|
1765
1905
|
}
|
|
1766
|
-
},
|
|
1906
|
+
}, _callee27, this, [[1, 3]]);
|
|
1767
1907
|
}));
|
|
1768
1908
|
function deregister() {
|
|
1769
1909
|
return _deregister.apply(this, arguments);
|
|
@@ -1813,7 +1953,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1813
1953
|
uri = !uri.endsWith('/') ? "".concat(uri, "/") : uri;
|
|
1814
1954
|
}
|
|
1815
1955
|
this.setActiveMobiusUrl(uri);
|
|
1816
|
-
this.registrationStatus =
|
|
1956
|
+
this.registrationStatus = _types3.RegistrationStatus.ACTIVE;
|
|
1817
1957
|
return true;
|
|
1818
1958
|
}
|
|
1819
1959
|
return false;
|
|
@@ -1831,10 +1971,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1831
1971
|
}, {
|
|
1832
1972
|
key: "reconnectOnFailure",
|
|
1833
1973
|
value: (function () {
|
|
1834
|
-
var _reconnectOnFailure = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
1974
|
+
var _reconnectOnFailure = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28(caller) {
|
|
1835
1975
|
var abort;
|
|
1836
|
-
return _regenerator.default.wrap(function (
|
|
1837
|
-
while (1) switch (
|
|
1976
|
+
return _regenerator.default.wrap(function (_context29) {
|
|
1977
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1838
1978
|
case 0:
|
|
1839
1979
|
_Logger.default.info(_constants.METHOD_START_MESSAGE, {
|
|
1840
1980
|
method: _constants2.METHODS.RECONNECT_ON_FAILURE,
|
|
@@ -1842,25 +1982,25 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1842
1982
|
});
|
|
1843
1983
|
this.reconnectPending = false;
|
|
1844
1984
|
if (this.isDeviceRegistered()) {
|
|
1845
|
-
|
|
1985
|
+
_context29.next = 4;
|
|
1846
1986
|
break;
|
|
1847
1987
|
}
|
|
1848
1988
|
if (!((0, _keys.default)(this.callManager.getActiveCalls()).length === 0)) {
|
|
1849
|
-
|
|
1989
|
+
_context29.next = 3;
|
|
1850
1990
|
break;
|
|
1851
1991
|
}
|
|
1852
|
-
|
|
1992
|
+
_context29.next = 1;
|
|
1853
1993
|
return this.restorePreviousRegistration(caller);
|
|
1854
1994
|
case 1:
|
|
1855
|
-
abort =
|
|
1995
|
+
abort = _context29.sent;
|
|
1856
1996
|
if (!(!abort && !this.isDeviceRegistered())) {
|
|
1857
|
-
|
|
1997
|
+
_context29.next = 2;
|
|
1858
1998
|
break;
|
|
1859
1999
|
}
|
|
1860
|
-
|
|
2000
|
+
_context29.next = 2;
|
|
1861
2001
|
return this.restartRegistration(caller);
|
|
1862
2002
|
case 2:
|
|
1863
|
-
|
|
2003
|
+
_context29.next = 4;
|
|
1864
2004
|
break;
|
|
1865
2005
|
case 3:
|
|
1866
2006
|
this.reconnectPending = true;
|
|
@@ -1870,11 +2010,11 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1870
2010
|
});
|
|
1871
2011
|
case 4:
|
|
1872
2012
|
case "end":
|
|
1873
|
-
return
|
|
2013
|
+
return _context29.stop();
|
|
1874
2014
|
}
|
|
1875
|
-
},
|
|
2015
|
+
}, _callee28, this);
|
|
1876
2016
|
}));
|
|
1877
|
-
function reconnectOnFailure(
|
|
2017
|
+
function reconnectOnFailure(_x22) {
|
|
1878
2018
|
return _reconnectOnFailure.apply(this, arguments);
|
|
1879
2019
|
}
|
|
1880
2020
|
return reconnectOnFailure;
|
|
@@ -1889,11 +2029,11 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1889
2029
|
}, {
|
|
1890
2030
|
key: "handleRegistrationDownEvent",
|
|
1891
2031
|
value: (function () {
|
|
1892
|
-
var _handleRegistrationDownEvent = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
2032
|
+
var _handleRegistrationDownEvent = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29(event) {
|
|
1893
2033
|
var _event$trackingId, _event$eventId;
|
|
1894
2034
|
var loggerContext, _Object$values, _Object$values2, activeCall;
|
|
1895
|
-
return _regenerator.default.wrap(function (
|
|
1896
|
-
while (1) switch (
|
|
2035
|
+
return _regenerator.default.wrap(function (_context30) {
|
|
2036
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1897
2037
|
case 0:
|
|
1898
2038
|
loggerContext = {
|
|
1899
2039
|
file: _constants2.REGISTRATION_FILE,
|
|
@@ -1902,50 +2042,56 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1902
2042
|
_Logger.default.info("Registration down received - trackingId: ".concat((_event$trackingId = event === null || event === void 0 ? void 0 : event.trackingId) !== null && _event$trackingId !== void 0 ? _event$trackingId : 'unknown', ", eventId: ").concat((_event$eventId = event === null || event === void 0 ? void 0 : event.eventId) !== null && _event$eventId !== void 0 ? _event$eventId : 'unknown'), loggerContext);
|
|
1903
2043
|
_Object$values = (0, _values.default)(this.callManager.getActiveCalls()), _Object$values2 = (0, _slicedToArray2.default)(_Object$values, 1), activeCall = _Object$values2[0];
|
|
1904
2044
|
activeCall === null || activeCall === void 0 ? void 0 : activeCall.end();
|
|
1905
|
-
|
|
1906
|
-
return this.
|
|
2045
|
+
_context30.next = 1;
|
|
2046
|
+
return this.registrationCleanup(_constants2.METHODS.HANDLE_REGISTRATION_DOWN_EVENT, {
|
|
2047
|
+
reason: _types2.HARD_STOP_REASON.REGISTRATION_DOWN
|
|
2048
|
+
});
|
|
1907
2049
|
case 1:
|
|
1908
2050
|
case "end":
|
|
1909
|
-
return
|
|
2051
|
+
return _context30.stop();
|
|
1910
2052
|
}
|
|
1911
|
-
},
|
|
2053
|
+
}, _callee29, this);
|
|
1912
2054
|
}));
|
|
1913
|
-
function handleRegistrationDownEvent(
|
|
2055
|
+
function handleRegistrationDownEvent(_x23) {
|
|
1914
2056
|
return _handleRegistrationDownEvent.apply(this, arguments);
|
|
1915
2057
|
}
|
|
1916
2058
|
return handleRegistrationDownEvent;
|
|
1917
2059
|
}()
|
|
1918
2060
|
/**
|
|
1919
|
-
* Cleans up registration-side state
|
|
2061
|
+
* Cleans up registration-side state for a hard stop, i.e. a registration that is gone
|
|
2062
|
+
* and must not be re-established by the SDK (Mobius registration-down event, or a
|
|
2063
|
+
* session superseded by another registration for the same user).
|
|
1920
2064
|
*
|
|
1921
2065
|
* Stops timers, resets transient flags, clears failover cache, sets status to
|
|
1922
2066
|
* INACTIVE, tears down the Mobius WebSocket (when enabled), and finally emits
|
|
1923
|
-
* `LINE_EVENTS.UNREGISTERED` so the SDK consumer is notified.
|
|
2067
|
+
* `LINE_EVENTS.UNREGISTERED` so the SDK consumer is notified. A superseded session
|
|
2068
|
+
* carries its `LineError` on that event as the reason the line will stay unregistered.
|
|
1924
2069
|
*
|
|
1925
2070
|
* Runs under the shared mutex to avoid racing with other registration flows.
|
|
1926
2071
|
*
|
|
1927
2072
|
* @param caller - Identifier of the caller, used for logs.
|
|
2073
|
+
* @param hardStop - Why the registration is being torn down as {@link HardStop}.
|
|
1928
2074
|
*/
|
|
1929
2075
|
)
|
|
1930
2076
|
}, {
|
|
1931
|
-
key: "
|
|
2077
|
+
key: "registrationCleanup",
|
|
1932
2078
|
value: (function () {
|
|
1933
|
-
var
|
|
2079
|
+
var _registrationCleanup = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee31(caller, hardStop) {
|
|
1934
2080
|
var _this0 = this;
|
|
1935
2081
|
var loggerContext;
|
|
1936
|
-
return _regenerator.default.wrap(function (
|
|
1937
|
-
while (1) switch (
|
|
2082
|
+
return _regenerator.default.wrap(function (_context32) {
|
|
2083
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
1938
2084
|
case 0:
|
|
1939
2085
|
loggerContext = {
|
|
1940
2086
|
file: _constants2.REGISTRATION_FILE,
|
|
1941
|
-
method:
|
|
2087
|
+
method: caller
|
|
1942
2088
|
};
|
|
1943
|
-
_Logger.default.info("[".concat(caller, "] : Running
|
|
1944
|
-
|
|
1945
|
-
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
2089
|
+
_Logger.default.info("[".concat(caller, "] : Running ").concat(hardStop.reason, " cleanup"), loggerContext);
|
|
2090
|
+
_context32.next = 1;
|
|
2091
|
+
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee30() {
|
|
1946
2092
|
var _t9;
|
|
1947
|
-
return _regenerator.default.wrap(function (
|
|
1948
|
-
while (1) switch (
|
|
2093
|
+
return _regenerator.default.wrap(function (_context31) {
|
|
2094
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1949
2095
|
case 0:
|
|
1950
2096
|
_this0.clearFailbackTimer();
|
|
1951
2097
|
_this0.clearKeepaliveTimer();
|
|
@@ -1955,43 +2101,43 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1955
2101
|
_this0.retryAfter = undefined;
|
|
1956
2102
|
_this0.registerRetry = false;
|
|
1957
2103
|
_this0.clearFailoverState();
|
|
1958
|
-
_this0.setStatus(
|
|
2104
|
+
_this0.setStatus(_types3.RegistrationStatus.INACTIVE);
|
|
1959
2105
|
if (!_this0.apiRequest.isSocketEnabled()) {
|
|
1960
|
-
|
|
2106
|
+
_context31.next = 4;
|
|
1961
2107
|
break;
|
|
1962
2108
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
2109
|
+
_context31.prev = 1;
|
|
2110
|
+
_context31.next = 2;
|
|
1965
2111
|
return _this0.apiRequest.disconnectFromMobiusSocket({
|
|
1966
2112
|
code: 3050,
|
|
1967
2113
|
reason: 'done (permanent)'
|
|
1968
2114
|
});
|
|
1969
2115
|
case 2:
|
|
1970
|
-
_Logger.default.log(
|
|
1971
|
-
|
|
2116
|
+
_Logger.default.log("Mobius socket disconnect complete after ".concat(hardStop.reason), loggerContext);
|
|
2117
|
+
_context31.next = 4;
|
|
1972
2118
|
break;
|
|
1973
2119
|
case 3:
|
|
1974
|
-
|
|
1975
|
-
_t9 =
|
|
1976
|
-
_Logger.default.warn("Mobius socket disconnect failed after
|
|
2120
|
+
_context31.prev = 3;
|
|
2121
|
+
_t9 = _context31["catch"](1);
|
|
2122
|
+
_Logger.default.warn("Mobius socket disconnect failed after ".concat(hardStop.reason, ": ").concat(String(_t9)), loggerContext);
|
|
1977
2123
|
case 4:
|
|
1978
|
-
_this0.lineEmitter(
|
|
2124
|
+
_this0.lineEmitter(_types4.LINE_EVENTS.UNREGISTERED, undefined, hardStop.error);
|
|
1979
2125
|
case 5:
|
|
1980
2126
|
case "end":
|
|
1981
|
-
return
|
|
2127
|
+
return _context31.stop();
|
|
1982
2128
|
}
|
|
1983
|
-
},
|
|
2129
|
+
}, _callee30, null, [[1, 3]]);
|
|
1984
2130
|
})));
|
|
1985
2131
|
case 1:
|
|
1986
2132
|
case "end":
|
|
1987
|
-
return
|
|
2133
|
+
return _context32.stop();
|
|
1988
2134
|
}
|
|
1989
|
-
},
|
|
2135
|
+
}, _callee31, this);
|
|
1990
2136
|
}));
|
|
1991
|
-
function
|
|
1992
|
-
return
|
|
2137
|
+
function registrationCleanup(_x24, _x25) {
|
|
2138
|
+
return _registrationCleanup.apply(this, arguments);
|
|
1993
2139
|
}
|
|
1994
|
-
return
|
|
2140
|
+
return registrationCleanup;
|
|
1995
2141
|
}())
|
|
1996
2142
|
}]);
|
|
1997
2143
|
}();
|