@webex/calling 3.12.0-task-refactor.1 → 3.12.0-webex-services-ready.1
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/CallHistory/CallHistory.js +68 -51
- package/dist/CallHistory/CallHistory.js.map +1 -1
- package/dist/CallRecording/CallRecording.js +160 -0
- package/dist/CallRecording/CallRecording.js.map +1 -0
- package/dist/CallRecording/CallRecording.test.js +257 -0
- package/dist/CallRecording/CallRecording.test.js.map +1 -0
- package/dist/CallRecording/WxcCallRecordingConnector.js +577 -0
- package/dist/CallRecording/WxcCallRecordingConnector.js.map +1 -0
- package/dist/CallRecording/WxcCallRecordingConnector.test.js +652 -0
- package/dist/CallRecording/WxcCallRecordingConnector.test.js.map +1 -0
- package/dist/CallRecording/callRecordingFixtures.js +235 -0
- package/dist/CallRecording/callRecordingFixtures.js.map +1 -0
- package/dist/CallRecording/constants.js +50 -0
- package/dist/CallRecording/constants.js.map +1 -0
- package/dist/CallRecording/types.js +137 -0
- package/dist/CallRecording/types.js.map +1 -0
- package/dist/CallRecording/utils.js +42 -0
- package/dist/CallRecording/utils.js.map +1 -0
- package/dist/CallRecording/utils.test.js +97 -0
- package/dist/CallRecording/utils.test.js.map +1 -0
- package/dist/CallingClient/CallingClient.js +520 -193
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +607 -133
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +599 -454
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +834 -443
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +88 -31
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +123 -0
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/calling/types.js +2 -0
- package/dist/CallingClient/calling/types.js.map +1 -1
- package/dist/CallingClient/constants.js +30 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +4 -1
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +16 -1
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +740 -407
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +380 -58
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.js +41 -104
- package/dist/CallingClient/registration/webWorker.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.test.js +39 -153
- package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
- package/dist/CallingClient/types.js.map +1 -1
- package/dist/CallingClient/utils/constants.js +58 -0
- package/dist/CallingClient/utils/constants.js.map +1 -0
- package/dist/CallingClient/utils/index.js +63 -0
- package/dist/CallingClient/utils/index.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js +122 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js +221 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js.map +1 -0
- package/dist/CallingClient/utils/request.js +435 -0
- package/dist/CallingClient/utils/request.js.map +1 -0
- package/dist/CallingClient/utils/request.test.js +999 -0
- package/dist/CallingClient/utils/request.test.js.map +1 -0
- package/dist/CallingClient/utils/types.js +7 -0
- package/dist/CallingClient/utils/types.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js +70 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js +139 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js.map +1 -0
- package/dist/Contacts/ContactsClient.js +13 -11
- package/dist/Contacts/ContactsClient.js.map +1 -1
- package/dist/Contacts/ContactsClient.test.js +3 -8
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Events/types.js +38 -11
- package/dist/Events/types.js.map +1 -1
- package/dist/Metrics/index.js +63 -2
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +357 -1
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js +19 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/api.js +56 -0
- package/dist/api.js.map +1 -1
- package/dist/common/Utils.js +161 -53
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +207 -46
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/common/testUtil.js +10 -5
- package/dist/common/testUtil.js.map +1 -1
- package/dist/common/types.js +3 -0
- package/dist/common/types.js.map +1 -1
- package/dist/index.js +165 -40
- package/dist/index.js.map +1 -1
- package/dist/mobius-socket/config.js +24 -0
- package/dist/mobius-socket/config.js.map +1 -0
- package/dist/mobius-socket/errors.js +143 -0
- package/dist/mobius-socket/errors.js.map +1 -0
- package/dist/mobius-socket/errors.test.js +20 -0
- package/dist/mobius-socket/errors.test.js.map +1 -0
- package/dist/mobius-socket/index.js +57 -0
- package/dist/mobius-socket/index.js.map +1 -0
- package/dist/mobius-socket/mobius-socket-events.test.js +492 -0
- package/dist/mobius-socket/mobius-socket-events.test.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.js +849 -0
- package/dist/mobius-socket/mobius-socket.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.test.js +1898 -0
- package/dist/mobius-socket/mobius-socket.test.js.map +1 -0
- package/dist/mobius-socket/socket/constants.js +55 -0
- package/dist/mobius-socket/socket/constants.js.map +1 -0
- package/dist/mobius-socket/socket/index.js +15 -0
- package/dist/mobius-socket/socket/index.js.map +1 -0
- package/dist/mobius-socket/socket/socket-base.js +604 -0
- package/dist/mobius-socket/socket/socket-base.js.map +1 -0
- package/dist/mobius-socket/socket/socket.js +19 -0
- package/dist/mobius-socket/socket/socket.js.map +1 -0
- package/dist/mobius-socket/socket/socket.shim.js +26 -0
- package/dist/mobius-socket/socket/socket.shim.js.map +1 -0
- package/dist/mobius-socket/socket/types.js +7 -0
- package/dist/mobius-socket/socket/types.js.map +1 -0
- package/dist/mobius-socket/socket.test.js +727 -0
- package/dist/mobius-socket/socket.test.js.map +1 -0
- package/dist/mobius-socket/test/mocha-helpers.js +23 -0
- package/dist/mobius-socket/test/mocha-helpers.js.map +1 -0
- package/dist/mobius-socket/test/promise-tick.js +28 -0
- package/dist/mobius-socket/test/promise-tick.js.map +1 -0
- package/dist/mobius-socket/types.js +7 -0
- package/dist/mobius-socket/types.js.map +1 -0
- package/dist/module/CallHistory/CallHistory.js +28 -17
- package/dist/module/CallRecording/CallRecording.js +56 -0
- package/dist/module/CallRecording/WxcCallRecordingConnector.js +257 -0
- package/dist/module/CallRecording/callRecordingFixtures.js +201 -0
- package/dist/module/CallRecording/constants.js +28 -0
- package/dist/module/CallRecording/types.js +19 -0
- package/dist/module/CallRecording/utils.js +14 -0
- package/dist/module/CallingClient/CallingClient.js +166 -8
- package/dist/module/CallingClient/calling/call.js +181 -64
- package/dist/module/CallingClient/calling/callManager.js +46 -7
- package/dist/module/CallingClient/calling/types.js +2 -0
- package/dist/module/CallingClient/constants.js +26 -0
- package/dist/module/CallingClient/line/index.js +2 -2
- package/dist/module/CallingClient/registration/register.js +247 -63
- package/dist/module/CallingClient/registration/webWorker.js +42 -61
- package/dist/module/CallingClient/registration/webWorkerStr.js +47 -82
- package/dist/module/CallingClient/utils/constants.js +36 -0
- package/dist/module/CallingClient/utils/index.js +5 -0
- package/dist/module/CallingClient/utils/mobiusSocketMapper.js +72 -0
- package/dist/module/CallingClient/utils/request.js +211 -0
- package/dist/module/CallingClient/utils/types.js +1 -0
- package/dist/module/CallingClient/utils/wsFeatureFlag.js +41 -0
- package/dist/module/Contacts/ContactsClient.js +1 -1
- package/dist/module/Events/types.js +23 -10
- package/dist/module/Metrics/index.js +48 -1
- package/dist/module/Metrics/types.js +18 -0
- package/dist/module/api.js +3 -2
- package/dist/module/common/Utils.js +65 -18
- package/dist/module/common/testUtil.js +6 -1
- package/dist/module/common/types.js +3 -0
- package/dist/module/index.js +7 -3
- package/dist/module/mobius-socket/config.js +15 -0
- package/dist/module/mobius-socket/errors.js +58 -0
- package/dist/module/mobius-socket/index.js +24 -0
- package/dist/module/mobius-socket/mobius-socket.js +593 -0
- package/dist/module/mobius-socket/socket/constants.js +26 -0
- package/dist/module/mobius-socket/socket/index.js +4 -0
- package/dist/module/mobius-socket/socket/socket-base.js +368 -0
- package/dist/module/mobius-socket/socket/socket.js +9 -0
- package/dist/module/mobius-socket/socket/socket.shim.js +12 -0
- package/dist/module/mobius-socket/socket/types.js +1 -0
- package/dist/module/mobius-socket/types.js +1 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallRecording/CallRecording.d.ts +18 -0
- package/dist/types/CallRecording/CallRecording.d.ts.map +1 -0
- package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts +23 -0
- package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts.map +1 -0
- package/dist/types/CallRecording/callRecordingFixtures.d.ts +61 -0
- package/dist/types/CallRecording/callRecordingFixtures.d.ts.map +1 -0
- package/dist/types/CallRecording/constants.d.ts +29 -0
- package/dist/types/CallRecording/constants.d.ts.map +1 -0
- package/dist/types/CallRecording/types.d.ts +176 -0
- package/dist/types/CallRecording/types.d.ts.map +1 -0
- package/dist/types/CallRecording/utils.d.ts +3 -0
- package/dist/types/CallRecording/utils.d.ts.map +1 -0
- package/dist/types/CallingClient/CallingClient.d.ts +10 -1
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts +12 -0
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts +4 -2
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/types.d.ts +34 -9
- package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +26 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts +1 -1
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +9 -2
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +6 -3
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
- package/dist/types/CallingClient/types.d.ts +3 -1
- package/dist/types/CallingClient/types.d.ts.map +1 -1
- package/dist/types/CallingClient/utils/constants.d.ts +35 -0
- package/dist/types/CallingClient/utils/constants.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/index.d.ts +6 -0
- package/dist/types/CallingClient/utils/index.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts +5 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/request.d.ts +28 -0
- package/dist/types/CallingClient/utils/request.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/types.d.ts +34 -0
- package/dist/types/CallingClient/utils/types.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts +4 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts.map +1 -0
- package/dist/types/Events/types.d.ts +79 -15
- package/dist/types/Events/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +19 -2
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +39 -12
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/api.d.ts +6 -4
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +11 -3
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +5 -1
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +9 -1
- package/dist/types/common/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mobius-socket/config.d.ts +17 -0
- package/dist/types/mobius-socket/config.d.ts.map +1 -0
- package/dist/types/mobius-socket/errors.d.ts +32 -0
- package/dist/types/mobius-socket/errors.d.ts.map +1 -0
- package/dist/types/mobius-socket/index.d.ts +14 -0
- package/dist/types/mobius-socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts +48 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/constants.d.ts +27 -0
- package/dist/types/mobius-socket/socket/constants.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/index.d.ts +5 -0
- package/dist/types/mobius-socket/socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts +43 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/types.d.ts +61 -0
- package/dist/types/mobius-socket/socket/types.d.ts.map +1 -0
- package/dist/types/mobius-socket/types.d.ts +21 -0
- package/dist/types/mobius-socket/types.d.ts.map +1 -0
- package/package.json +20 -5
- package/src/mobius-socket/socket/socket.shim.ts +22 -0
- package/src/mobius-socket/socket/socket.ts +14 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { v4 as uuid } from 'uuid';
|
|
2
1
|
import { METHOD_START_MESSAGE } from '../../common/constants';
|
|
3
2
|
import { emitFinalFailure, handleRegistrationErrors, uploadLogs } from '../../common';
|
|
4
3
|
import webWorkerStr from './webWorkerStr';
|
|
@@ -8,8 +7,9 @@ import { getCallManager } from '../calling';
|
|
|
8
7
|
import log from '../../Logger';
|
|
9
8
|
import SDKConnector from '../../SDKConnector';
|
|
10
9
|
import { ALLOWED_SERVICES, HTTP_METHODS, RegistrationStatus, ServiceIndicator, WorkerMessageType, } from '../../common/types';
|
|
11
|
-
import { CALLING_USER_AGENT, CISCO_DEVICE_URL, DEVICES_ENDPOINT_RESOURCE, SPARK_USER_AGENT,
|
|
10
|
+
import { CALLING_USER_AGENT, CISCO_DEVICE_URL, DEVICES_ENDPOINT_RESOURCE, SPARK_USER_AGENT, BASE_REG_RETRY_TIMER_VAL_IN_SEC, BASE_REG_TIMER_MFACTOR, SEC_TO_MSEC_MFACTOR, REG_RANDOM_T_FACTOR_UPPER_LIMIT, REG_TRY_BACKUP_TIMER_VAL_IN_SEC, MINUTES_TO_SEC_MFACTOR, REG_429_RETRY_UTIL, REG_FAILBACK_429_MAX_RETRIES, FAILBACK_UTIL, REGISTRATION_FILE, DEFAULT_REHOMING_INTERVAL_MIN, DEFAULT_REHOMING_INTERVAL_MAX, DEFAULT_KEEPALIVE_INTERVAL, FAILOVER_UTIL, REGISTER_UTIL, RETRY_TIMER_UPPER_LIMIT, KEEPALIVE_UTIL, REGISTRATION_UTIL, METHODS, URL_ENDPOINT, RECONNECT_ON_FAILURE_UTIL, FAILOVER_CACHE_PREFIX, } from '../constants';
|
|
12
11
|
import { LINE_EVENTS } from '../line/types';
|
|
12
|
+
import { APIRequest } from '../utils/request';
|
|
13
13
|
export class Registration {
|
|
14
14
|
sdkConnector;
|
|
15
15
|
webex;
|
|
@@ -36,6 +36,7 @@ export class Registration {
|
|
|
36
36
|
retryAfter;
|
|
37
37
|
scheduled429Retry = false;
|
|
38
38
|
webWorker;
|
|
39
|
+
apiRequest;
|
|
39
40
|
constructor(webex, serviceData, mutex, lineEmitter, logLevel, jwe) {
|
|
40
41
|
this.jwe = jwe;
|
|
41
42
|
this.sdkConnector = SDKConnector;
|
|
@@ -57,6 +58,12 @@ export class Registration {
|
|
|
57
58
|
this.lineEmitter = lineEmitter;
|
|
58
59
|
this.primaryMobiusUris = [];
|
|
59
60
|
this.backupMobiusUris = [];
|
|
61
|
+
this.apiRequest = APIRequest.getInstance({ webex: this.webex });
|
|
62
|
+
}
|
|
63
|
+
getServerType(url) {
|
|
64
|
+
return ((this.primaryMobiusUris.includes(url) && 'PRIMARY') ||
|
|
65
|
+
(this.backupMobiusUris?.includes(url) && 'BACKUP') ||
|
|
66
|
+
'UNKNOWN');
|
|
60
67
|
}
|
|
61
68
|
getFailoverCacheKey() {
|
|
62
69
|
return `${FAILOVER_CACHE_PREFIX}.${this.userId || 'unknown'}`;
|
|
@@ -116,6 +123,14 @@ export class Registration {
|
|
|
116
123
|
this.activeMobiusUrl = url;
|
|
117
124
|
this.callManager.updateActiveMobius(url);
|
|
118
125
|
}
|
|
126
|
+
setDeviceInfo(devicesInfo) {
|
|
127
|
+
const [device] = devicesInfo.devices;
|
|
128
|
+
this.deviceInfo = {
|
|
129
|
+
userId: devicesInfo.userId,
|
|
130
|
+
device,
|
|
131
|
+
devices: devicesInfo.devices,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
119
134
|
setMobiusServers(primaryMobiusUris, backupMobiusUris) {
|
|
120
135
|
log.log(METHOD_START_MESSAGE, { method: METHODS.SET_MOBIUS_SERVERS, file: REGISTRATION_FILE });
|
|
121
136
|
this.primaryMobiusUris = primaryMobiusUris;
|
|
@@ -123,16 +138,22 @@ export class Registration {
|
|
|
123
138
|
}
|
|
124
139
|
async deleteRegistration(url, deviceId, deviceUrl) {
|
|
125
140
|
let response;
|
|
141
|
+
const requestObj = {
|
|
142
|
+
uri: `${url}${DEVICES_ENDPOINT_RESOURCE}/${deviceId}`,
|
|
143
|
+
method: HTTP_METHODS.DELETE,
|
|
144
|
+
headers: {
|
|
145
|
+
[CISCO_DEVICE_URL]: deviceUrl,
|
|
146
|
+
[SPARK_USER_AGENT]: CALLING_USER_AGENT,
|
|
147
|
+
},
|
|
148
|
+
service: ALLOWED_SERVICES.MOBIUS,
|
|
149
|
+
};
|
|
150
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
151
|
+
requestObj.body = {
|
|
152
|
+
deviceId,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
126
155
|
try {
|
|
127
|
-
response = await
|
|
128
|
-
method: HTTP_METHODS.DELETE,
|
|
129
|
-
headers: {
|
|
130
|
-
[CISCO_DEVICE_URL]: deviceUrl,
|
|
131
|
-
Authorization: await this.webex.credentials.getUserToken(),
|
|
132
|
-
trackingId: `${WEBEX_WEB_CLIENT}_${uuid()}`,
|
|
133
|
-
[SPARK_USER_AGENT]: CALLING_USER_AGENT,
|
|
134
|
-
},
|
|
135
|
-
});
|
|
156
|
+
response = await this.apiRequest.makeRequest(requestObj);
|
|
136
157
|
}
|
|
137
158
|
catch (error) {
|
|
138
159
|
log.warn(`Delete failed with Mobius: ${JSON.stringify(error)}`, {
|
|
@@ -143,7 +164,7 @@ export class Registration {
|
|
|
143
164
|
}
|
|
144
165
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
145
166
|
this.lineEmitter(LINE_EVENTS.UNREGISTERED);
|
|
146
|
-
return response
|
|
167
|
+
return response;
|
|
147
168
|
}
|
|
148
169
|
async postRegistration(url) {
|
|
149
170
|
const deviceInfo = {
|
|
@@ -151,7 +172,7 @@ export class Registration {
|
|
|
151
172
|
clientDeviceUri: this.webex.internal.device.url,
|
|
152
173
|
serviceData: this.jwe ? { ...this.serviceData, jwe: this.jwe } : this.serviceData,
|
|
153
174
|
};
|
|
154
|
-
return this.
|
|
175
|
+
return this.apiRequest.makeRequest({
|
|
155
176
|
uri: `${url}device`,
|
|
156
177
|
method: HTTP_METHODS.POST,
|
|
157
178
|
headers: {
|
|
@@ -163,7 +184,23 @@ export class Registration {
|
|
|
163
184
|
});
|
|
164
185
|
}
|
|
165
186
|
async restorePreviousRegistration(caller) {
|
|
187
|
+
const loggerContext = {
|
|
188
|
+
file: REGISTRATION_FILE,
|
|
189
|
+
method: METHODS.RESTORE_PREVIOUS_REGISTRATION,
|
|
190
|
+
};
|
|
191
|
+
log.info(`${METHOD_START_MESSAGE} - caller: ${caller}, activeMobiusUrl: ${this.activeMobiusUrl}`, loggerContext);
|
|
166
192
|
let abort = false;
|
|
193
|
+
if (this.apiRequest.isSocketEnabled() &&
|
|
194
|
+
`${this.apiRequest.getConnectedWebSocketUrl()}/` !== this.activeMobiusUrl) {
|
|
195
|
+
log.info(`Disconnecting from Mobius socket to restore previous registration.`, {
|
|
196
|
+
file: REGISTRATION_FILE,
|
|
197
|
+
method: 'restorePreviousRegistration',
|
|
198
|
+
});
|
|
199
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
200
|
+
code: 3050,
|
|
201
|
+
reason: 'done (permanent)',
|
|
202
|
+
});
|
|
203
|
+
}
|
|
167
204
|
if (this.activeMobiusUrl) {
|
|
168
205
|
abort = await this.attemptRegistrationWithServers(caller, [this.activeMobiusUrl]);
|
|
169
206
|
if (this.retryAfter) {
|
|
@@ -177,20 +214,31 @@ export class Registration {
|
|
|
177
214
|
abort = await this.attemptRegistrationWithServers(caller, this.backupMobiusUris);
|
|
178
215
|
}
|
|
179
216
|
else {
|
|
180
|
-
this.restartRegistration(caller);
|
|
217
|
+
await this.restartRegistration(caller);
|
|
181
218
|
}
|
|
182
219
|
this.retryAfter = undefined;
|
|
220
|
+
log.log(`restorePreviousRegistration completed via 429 retry-after path - caller: ${caller}`, loggerContext);
|
|
183
221
|
return true;
|
|
184
222
|
}
|
|
185
223
|
}
|
|
224
|
+
log.log(`restorePreviousRegistration completed - caller: ${caller}, deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
186
225
|
return abort;
|
|
187
226
|
}
|
|
188
227
|
async handle404KeepaliveFailure(caller) {
|
|
228
|
+
const loggerContext = {
|
|
229
|
+
file: REGISTRATION_FILE,
|
|
230
|
+
method: METHODS.HANDLE_404_KEEPALIVE_FAILURE,
|
|
231
|
+
};
|
|
232
|
+
log.info(`${METHOD_START_MESSAGE} - caller: ${caller}`, loggerContext);
|
|
189
233
|
if (caller === KEEPALIVE_UTIL) {
|
|
190
234
|
const abort = await this.attemptRegistrationWithServers(caller);
|
|
191
235
|
if (!abort && !this.isDeviceRegistered()) {
|
|
236
|
+
log.warn('Keepalive 404 recovery: re-registration did not complete, starting failover timer', loggerContext);
|
|
192
237
|
await this.startFailoverTimer();
|
|
193
238
|
}
|
|
239
|
+
else {
|
|
240
|
+
log.log(`Keepalive 404 recovery handled - deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
241
|
+
}
|
|
194
242
|
}
|
|
195
243
|
}
|
|
196
244
|
async handle429Retry(retryAfter, caller) {
|
|
@@ -220,7 +268,7 @@ export class Registration {
|
|
|
220
268
|
method: REG_429_RETRY_UTIL,
|
|
221
269
|
});
|
|
222
270
|
await this.startKeepaliveTimer(this.deviceInfo.device?.uri, this.deviceInfo.keepaliveInterval, 'UNKNOWN');
|
|
223
|
-
}, retryAfter * 1000);
|
|
271
|
+
}, (retryAfter - Number(this.deviceInfo.keepaliveInterval || 0)) * 1000);
|
|
224
272
|
}
|
|
225
273
|
else {
|
|
226
274
|
this.retryAfter = retryAfter;
|
|
@@ -271,6 +319,14 @@ export class Registration {
|
|
|
271
319
|
log.log(`Scheduled retry with primary in ${interval} seconds, number of attempts : ${attempt}`, loggerContext);
|
|
272
320
|
}
|
|
273
321
|
else if (this.backupMobiusUris.length) {
|
|
322
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
323
|
+
log.info('Disconnecting from primary Mobius socket for failover to backup servers', loggerContext);
|
|
324
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
325
|
+
code: 3050,
|
|
326
|
+
reason: 'done (permanent)',
|
|
327
|
+
});
|
|
328
|
+
log.log('Mobius socket disconnect complete prior to backup failover', loggerContext);
|
|
329
|
+
}
|
|
274
330
|
this.saveFailoverState({
|
|
275
331
|
attempt,
|
|
276
332
|
timeElapsed,
|
|
@@ -303,7 +359,7 @@ export class Registration {
|
|
|
303
359
|
await uploadLogs();
|
|
304
360
|
emitFinalFailure((clientError) => {
|
|
305
361
|
this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
|
|
306
|
-
}, loggerContext);
|
|
362
|
+
}, loggerContext, interval < 0 ? 'Timer threshold exceeded during failover' : undefined);
|
|
307
363
|
}
|
|
308
364
|
}
|
|
309
365
|
clearFailbackTimer() {
|
|
@@ -312,11 +368,25 @@ export class Registration {
|
|
|
312
368
|
this.failbackTimer = undefined;
|
|
313
369
|
}
|
|
314
370
|
}
|
|
371
|
+
async postKeepAlive(deviceUrl, url) {
|
|
372
|
+
return this.apiRequest.makeRequest({
|
|
373
|
+
uri: `${url}/status`,
|
|
374
|
+
method: HTTP_METHODS.POST,
|
|
375
|
+
headers: {
|
|
376
|
+
[CISCO_DEVICE_URL]: deviceUrl,
|
|
377
|
+
[SPARK_USER_AGENT]: CALLING_USER_AGENT,
|
|
378
|
+
},
|
|
379
|
+
body: {
|
|
380
|
+
deviceId: this.deviceInfo.device?.deviceId,
|
|
381
|
+
},
|
|
382
|
+
service: ALLOWED_SERVICES.MOBIUS,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
315
385
|
async isPrimaryActive() {
|
|
316
386
|
let status;
|
|
317
387
|
for (const mobiusUrl of this.primaryMobiusUris) {
|
|
318
388
|
try {
|
|
319
|
-
const baseUri = mobiusUrl.replace(URL_ENDPOINT, '/');
|
|
389
|
+
const baseUri = mobiusUrl.replace(URL_ENDPOINT, '/').replace('wss://', 'https://');
|
|
320
390
|
const response = await this.webex.request({
|
|
321
391
|
uri: `${baseUri}ping`,
|
|
322
392
|
method: HTTP_METHODS.GET,
|
|
@@ -354,14 +424,23 @@ export class Registration {
|
|
|
354
424
|
this.rehomingIntervalMin);
|
|
355
425
|
}
|
|
356
426
|
initiateFailback() {
|
|
427
|
+
const loggerContext = {
|
|
428
|
+
file: REGISTRATION_FILE,
|
|
429
|
+
method: METHODS.INITIATE_FAILBACK,
|
|
430
|
+
};
|
|
357
431
|
if (this.isFailbackRequired()) {
|
|
358
432
|
if (!this.failbackTimer) {
|
|
359
433
|
this.failback429RetryAttempts = 0;
|
|
360
434
|
const intervalInMinutes = this.getFailbackInterval();
|
|
435
|
+
log.info(`Scheduling failback to primary - intervalMinutes: ${intervalInMinutes}`, loggerContext);
|
|
361
436
|
this.startFailbackTimer(intervalInMinutes * MINUTES_TO_SEC_MFACTOR);
|
|
362
437
|
}
|
|
438
|
+
else {
|
|
439
|
+
log.info('Failback timer already scheduled, skipping', loggerContext);
|
|
440
|
+
}
|
|
363
441
|
}
|
|
364
442
|
else {
|
|
443
|
+
log.info('Failback not required, clearing any pending failback timer', loggerContext);
|
|
365
444
|
this.failback429RetryAttempts = 0;
|
|
366
445
|
this.clearFailbackTimer();
|
|
367
446
|
}
|
|
@@ -374,15 +453,25 @@ export class Registration {
|
|
|
374
453
|
});
|
|
375
454
|
}
|
|
376
455
|
async executeFailback() {
|
|
456
|
+
const loggerContext = {
|
|
457
|
+
file: REGISTRATION_FILE,
|
|
458
|
+
method: METHODS.EXECUTE_FAILBACK,
|
|
459
|
+
};
|
|
460
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
377
461
|
await this.mutex.runExclusive(async () => {
|
|
378
462
|
if (this.isFailbackRequired()) {
|
|
379
463
|
const primaryServerStatus = await this.isPrimaryActive();
|
|
380
464
|
if (Object.keys(this.callManager.getActiveCalls()).length === 0 && primaryServerStatus) {
|
|
381
|
-
log.info(`Attempting failback to primary.`,
|
|
382
|
-
file: REGISTRATION_FILE,
|
|
383
|
-
method: this.executeFailback.name,
|
|
384
|
-
});
|
|
465
|
+
log.info(`Attempting failback to primary.`, loggerContext);
|
|
385
466
|
await this.deregister();
|
|
467
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
468
|
+
log.info('Disconnecting from backup Mobius socket for failback to primary', loggerContext);
|
|
469
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
470
|
+
code: 3050,
|
|
471
|
+
reason: 'done (permanent)',
|
|
472
|
+
});
|
|
473
|
+
log.log('Mobius socket disconnect complete prior to primary failback', loggerContext);
|
|
474
|
+
}
|
|
386
475
|
const abort = await this.attemptRegistrationWithServers(FAILBACK_UTIL);
|
|
387
476
|
if (this.scheduled429Retry || abort || this.isDeviceRegistered()) {
|
|
388
477
|
return;
|
|
@@ -393,7 +482,7 @@ export class Registration {
|
|
|
393
482
|
return;
|
|
394
483
|
}
|
|
395
484
|
if (!this.isDeviceRegistered()) {
|
|
396
|
-
await this.restartRegistration(
|
|
485
|
+
await this.restartRegistration(loggerContext.method);
|
|
397
486
|
}
|
|
398
487
|
else {
|
|
399
488
|
this.failbackTimer = undefined;
|
|
@@ -401,10 +490,7 @@ export class Registration {
|
|
|
401
490
|
}
|
|
402
491
|
}
|
|
403
492
|
else {
|
|
404
|
-
log.info('Active calls present or primary Mobius is down, deferring failback to next cycle.',
|
|
405
|
-
file: REGISTRATION_FILE,
|
|
406
|
-
method: this.executeFailback.name,
|
|
407
|
-
});
|
|
493
|
+
log.info('Active calls present or primary Mobius is down, deferring failback to next cycle.', loggerContext);
|
|
408
494
|
this.failbackTimer = undefined;
|
|
409
495
|
this.initiateFailback();
|
|
410
496
|
}
|
|
@@ -434,12 +520,18 @@ export class Registration {
|
|
|
434
520
|
this.registrationStatus = value;
|
|
435
521
|
}
|
|
436
522
|
async restartRegistration(caller) {
|
|
523
|
+
const loggerContext = {
|
|
524
|
+
file: REGISTRATION_FILE,
|
|
525
|
+
method: METHODS.RESTART_REGISTRATION,
|
|
526
|
+
};
|
|
527
|
+
log.info(`${METHOD_START_MESSAGE} - caller: ${caller}`, loggerContext);
|
|
437
528
|
this.clearFailbackTimer();
|
|
438
529
|
this.failback429RetryAttempts = 0;
|
|
439
530
|
const abort = await this.attemptRegistrationWithServers(caller, this.primaryMobiusUris);
|
|
440
531
|
if (!abort && !this.isDeviceRegistered()) {
|
|
441
532
|
await this.startFailoverTimer();
|
|
442
533
|
}
|
|
534
|
+
log.log(`restartRegistration completed - caller: ${caller}, deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
443
535
|
}
|
|
444
536
|
async handleConnectionRestoration(retry) {
|
|
445
537
|
log.info(METHOD_START_MESSAGE, {
|
|
@@ -492,7 +584,13 @@ export class Registration {
|
|
|
492
584
|
};
|
|
493
585
|
}
|
|
494
586
|
async triggerRegistration() {
|
|
587
|
+
const loggerContext = {
|
|
588
|
+
file: REGISTRATION_FILE,
|
|
589
|
+
method: METHODS.TRIGGER_REGISTRATION,
|
|
590
|
+
};
|
|
591
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
495
592
|
if (await this.resumeFailover()) {
|
|
593
|
+
log.info('Registration trigger handled by resumeFailover path', loggerContext);
|
|
496
594
|
return;
|
|
497
595
|
}
|
|
498
596
|
if (this.primaryMobiusUris.length > 0) {
|
|
@@ -500,43 +598,51 @@ export class Registration {
|
|
|
500
598
|
if (!this.isDeviceRegistered() && !abort) {
|
|
501
599
|
await this.startFailoverTimer();
|
|
502
600
|
}
|
|
601
|
+
log.log(`triggerRegistration completed - deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
602
|
+
}
|
|
603
|
+
else {
|
|
604
|
+
log.warn('triggerRegistration skipped: no primary Mobius URIs available', loggerContext);
|
|
503
605
|
}
|
|
504
606
|
}
|
|
505
607
|
async attemptRegistrationWithServers(caller, servers = this.primaryMobiusUris) {
|
|
608
|
+
const loggerContext = {
|
|
609
|
+
file: REGISTRATION_FILE,
|
|
610
|
+
method: REGISTER_UTIL,
|
|
611
|
+
};
|
|
506
612
|
let abort = false;
|
|
507
613
|
this.retryAfter = undefined;
|
|
614
|
+
let connectedWebSocketUrl;
|
|
508
615
|
if (this.failoverImmediately) {
|
|
509
616
|
return abort;
|
|
510
617
|
}
|
|
511
618
|
if (this.isDeviceRegistered()) {
|
|
512
|
-
log.info(`[${caller}] : Device already registered with : ${this.activeMobiusUrl}`,
|
|
513
|
-
file: REGISTRATION_FILE,
|
|
514
|
-
method: REGISTER_UTIL,
|
|
515
|
-
});
|
|
619
|
+
log.info(`[${caller}] : Device already registered with : ${this.activeMobiusUrl}`, loggerContext);
|
|
516
620
|
return abort;
|
|
517
621
|
}
|
|
622
|
+
if (servers.length) {
|
|
623
|
+
this.apiRequest.setSocketEnabled(servers[0].startsWith('wss://'));
|
|
624
|
+
}
|
|
518
625
|
for (const url of servers) {
|
|
519
|
-
const serverType =
|
|
520
|
-
(this.backupMobiusUris?.includes(url) && 'BACKUP') ||
|
|
521
|
-
'UNKNOWN';
|
|
626
|
+
const serverType = this.getServerType(url);
|
|
522
627
|
try {
|
|
523
628
|
abort = false;
|
|
524
629
|
this.registrationStatus = RegistrationStatus.INACTIVE;
|
|
525
630
|
this.lineEmitter(LINE_EVENTS.CONNECTING);
|
|
526
|
-
log.info(`[${caller}] : Mobius url to contact: ${url}`,
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
631
|
+
log.info(`[${caller}] : Mobius url to contact: ${url}`, loggerContext);
|
|
632
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
633
|
+
const wssNormalizedUrl = url.endsWith('/') ? url.slice(0, -1) : url;
|
|
634
|
+
log.info(`[${caller}] : Connecting to Mobius WebSocket - serverType: ${serverType}, wssUrl: ${wssNormalizedUrl}`, loggerContext);
|
|
635
|
+
connectedWebSocketUrl = await this.apiRequest.connectToMobiusSocket(wssNormalizedUrl);
|
|
636
|
+
connectedWebSocketUrl = connectedWebSocketUrl ? `${connectedWebSocketUrl}/` : undefined;
|
|
637
|
+
log.log(`[${caller}] : Mobius WebSocket connected - serverType: ${serverType}, connectedWebSocketUrl: ${connectedWebSocketUrl}`, loggerContext);
|
|
638
|
+
}
|
|
530
639
|
const resp = await this.postRegistration(url);
|
|
531
640
|
this.clearFailoverState();
|
|
532
641
|
this.deviceInfo = resp.body;
|
|
533
642
|
this.registrationStatus = RegistrationStatus.ACTIVE;
|
|
534
|
-
this.setActiveMobiusUrl(url);
|
|
643
|
+
this.setActiveMobiusUrl(connectedWebSocketUrl || url);
|
|
535
644
|
this.lineEmitter(LINE_EVENTS.REGISTERED, resp.body);
|
|
536
|
-
log.log(`Registration successful for deviceId: ${this.deviceInfo.device?.deviceId} userId: ${this.userId} responseTrackingId: ${resp.headers?.trackingid}`,
|
|
537
|
-
file: REGISTRATION_FILE,
|
|
538
|
-
method: METHODS.REGISTER,
|
|
539
|
-
});
|
|
645
|
+
log.log(`Registration successful for deviceId: ${this.deviceInfo.device?.deviceId} userId: ${this.userId} responseTrackingId: ${resp.headers?.trackingid}`, loggerContext);
|
|
540
646
|
this.setIntervalValues(this.deviceInfo);
|
|
541
647
|
this.metricManager.setDeviceInfo(this.deviceInfo);
|
|
542
648
|
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, caller, serverType, resp.headers?.trackingid ?? '', undefined, undefined);
|
|
@@ -546,22 +652,29 @@ export class Registration {
|
|
|
546
652
|
}
|
|
547
653
|
catch (err) {
|
|
548
654
|
const body = err;
|
|
549
|
-
|
|
550
|
-
if (
|
|
655
|
+
const { finalError, shouldDisconnect } = await handleRegistrationErrors(body, (clientError, isFinalError) => {
|
|
656
|
+
if (isFinalError) {
|
|
551
657
|
this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
|
|
552
658
|
}
|
|
553
659
|
else {
|
|
554
660
|
this.lineEmitter(LINE_EVENTS.UNREGISTERED);
|
|
555
661
|
}
|
|
556
662
|
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION_ERROR, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, caller, serverType, body.headers?.trackingid ?? '', undefined, clientError);
|
|
557
|
-
}, { method: caller, file: REGISTRATION_FILE }, (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller), this.restoreRegistrationCallBack());
|
|
663
|
+
}, { method: caller, file: REGISTRATION_FILE }, (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller), this.restoreRegistrationCallBack(), servers.length);
|
|
664
|
+
abort = finalError;
|
|
558
665
|
if (this.registrationStatus === RegistrationStatus.ACTIVE) {
|
|
559
|
-
log.info(`[${caller}] : Device is already restored, active mobius url: ${this.activeMobiusUrl}`,
|
|
560
|
-
file: REGISTRATION_FILE,
|
|
561
|
-
method: this.attemptRegistrationWithServers.name,
|
|
562
|
-
});
|
|
666
|
+
log.info(`[${caller}] : Device is already restored, active mobius url: ${this.activeMobiusUrl}`, loggerContext);
|
|
563
667
|
break;
|
|
564
668
|
}
|
|
669
|
+
if (shouldDisconnect && this.apiRequest.isSocketEnabled()) {
|
|
670
|
+
connectedWebSocketUrl = undefined;
|
|
671
|
+
log.info(`[${caller}] : Tearing down Mobius WebSocket after registration error - serverType: ${serverType}`, loggerContext);
|
|
672
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
673
|
+
code: 3050,
|
|
674
|
+
reason: 'done (permanent)',
|
|
675
|
+
});
|
|
676
|
+
log.log(`[${caller}] : Mobius WebSocket disconnect complete after registration error - serverType: ${serverType}`, loggerContext);
|
|
677
|
+
}
|
|
565
678
|
if (abort) {
|
|
566
679
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
567
680
|
await uploadLogs();
|
|
@@ -576,7 +689,6 @@ export class Registration {
|
|
|
576
689
|
const RETRY_COUNT_THRESHOLD = this.isCCFlow ? 4 : 5;
|
|
577
690
|
await this.mutex.runExclusive(async () => {
|
|
578
691
|
if (this.isDeviceRegistered()) {
|
|
579
|
-
const accessToken = await this.webex.credentials.getUserToken();
|
|
580
692
|
if (!this.webWorker) {
|
|
581
693
|
const blob = new Blob([webWorkerStr], { type: 'application/javascript' });
|
|
582
694
|
const blobUrl = URL.createObjectURL(blob);
|
|
@@ -584,17 +696,38 @@ export class Registration {
|
|
|
584
696
|
URL.revokeObjectURL(blobUrl);
|
|
585
697
|
this.webWorker.postMessage({
|
|
586
698
|
type: WorkerMessageType.START_KEEPALIVE,
|
|
587
|
-
accessToken: String(accessToken),
|
|
588
|
-
deviceUrl: String(this.webex.internal.device.url),
|
|
589
699
|
interval,
|
|
590
700
|
retryCountThreshold: RETRY_COUNT_THRESHOLD,
|
|
591
|
-
url,
|
|
592
701
|
});
|
|
593
702
|
this.webWorker.onmessage = async (event) => {
|
|
594
703
|
const logContext = {
|
|
595
704
|
file: REGISTRATION_FILE,
|
|
596
705
|
method: KEEPALIVE_UTIL,
|
|
597
706
|
};
|
|
707
|
+
if (event.data.type === WorkerMessageType.SEND_KEEPALIVE) {
|
|
708
|
+
try {
|
|
709
|
+
const res = await this.postKeepAlive(String(this.webex.internal.device.url), url);
|
|
710
|
+
this.webWorker?.postMessage({
|
|
711
|
+
type: WorkerMessageType.KEEPALIVE_RESULT,
|
|
712
|
+
statusCode: res.statusCode,
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
catch (err) {
|
|
716
|
+
const error = {
|
|
717
|
+
headers: {
|
|
718
|
+
trackingid: err.headers?.trackingid,
|
|
719
|
+
'retry-after': err.headers['retry-after'],
|
|
720
|
+
},
|
|
721
|
+
statusCode: err.statusCode,
|
|
722
|
+
statusText: err.statusText,
|
|
723
|
+
type: err.type,
|
|
724
|
+
};
|
|
725
|
+
this.webWorker?.postMessage({
|
|
726
|
+
type: WorkerMessageType.KEEPALIVE_RESULT,
|
|
727
|
+
err: error,
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
}
|
|
598
731
|
if (event.data.type === WorkerMessageType.KEEPALIVE_SUCCESS) {
|
|
599
732
|
log.info(`Sent Keepalive, status: ${event.data.statusCode}`, logContext);
|
|
600
733
|
this.lineEmitter(LINE_EVENTS.RECONNECTED);
|
|
@@ -602,7 +735,7 @@ export class Registration {
|
|
|
602
735
|
if (event.data.type === WorkerMessageType.KEEPALIVE_FAILURE) {
|
|
603
736
|
const error = event.data.err;
|
|
604
737
|
log.warn(`Keep-alive missed ${event.data.keepAliveRetryCount} times. Status -> ${error.statusCode} `, logContext);
|
|
605
|
-
const abort = await handleRegistrationErrors(error, (clientError, finalError) => {
|
|
738
|
+
const { finalError: abort } = await handleRegistrationErrors(error, (clientError, finalError) => {
|
|
606
739
|
if (finalError) {
|
|
607
740
|
this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
|
|
608
741
|
}
|
|
@@ -641,19 +774,25 @@ export class Registration {
|
|
|
641
774
|
isReconnectPending() {
|
|
642
775
|
return this.reconnectPending;
|
|
643
776
|
}
|
|
644
|
-
async deregister() {
|
|
777
|
+
async deregister(closeMobiusWss = false) {
|
|
778
|
+
const loggerContext = {
|
|
779
|
+
file: REGISTRATION_FILE,
|
|
780
|
+
method: METHODS.DEREGISTER,
|
|
781
|
+
};
|
|
782
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
645
783
|
try {
|
|
646
784
|
await this.deleteRegistration(this.activeMobiusUrl, this.deviceInfo.device?.deviceId, this.deviceInfo.device?.clientDeviceUri);
|
|
647
|
-
log.log('Registration successfully deregistered',
|
|
648
|
-
file: REGISTRATION_FILE,
|
|
649
|
-
method: METHODS.DEREGISTER,
|
|
650
|
-
});
|
|
785
|
+
log.log('Registration successfully deregistered', loggerContext);
|
|
651
786
|
}
|
|
652
787
|
catch (err) {
|
|
653
|
-
log.warn(`Delete failed with Mobius: ${JSON.stringify(err)}`,
|
|
654
|
-
|
|
655
|
-
|
|
788
|
+
log.warn(`Delete failed with Mobius: ${JSON.stringify(err)}`, loggerContext);
|
|
789
|
+
}
|
|
790
|
+
if (closeMobiusWss) {
|
|
791
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
792
|
+
code: 3050,
|
|
793
|
+
reason: 'done (permanent)',
|
|
656
794
|
});
|
|
795
|
+
log.log('Mobius socket disconnect complete after deregistration', loggerContext);
|
|
657
796
|
}
|
|
658
797
|
this.clearKeepaliveTimer();
|
|
659
798
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
@@ -675,7 +814,11 @@ export class Registration {
|
|
|
675
814
|
rehomingIntervalMin: DEFAULT_REHOMING_INTERVAL_MIN,
|
|
676
815
|
};
|
|
677
816
|
const stringToReplace = `${DEVICES_ENDPOINT_RESOURCE}/${restoreData.devices[0].deviceId}`;
|
|
678
|
-
|
|
817
|
+
let uri = restoreData.devices[0].uri.replace(stringToReplace, '');
|
|
818
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
819
|
+
uri = uri.replace('https://', 'wss://');
|
|
820
|
+
uri = !uri.endsWith('/') ? `${uri}/` : uri;
|
|
821
|
+
}
|
|
679
822
|
this.setActiveMobiusUrl(uri);
|
|
680
823
|
this.registrationStatus = RegistrationStatus.ACTIVE;
|
|
681
824
|
return true;
|
|
@@ -701,5 +844,46 @@ export class Registration {
|
|
|
701
844
|
}
|
|
702
845
|
}
|
|
703
846
|
}
|
|
847
|
+
async handleRegistrationDownEvent(event) {
|
|
848
|
+
const loggerContext = {
|
|
849
|
+
file: REGISTRATION_FILE,
|
|
850
|
+
method: METHODS.HANDLE_REGISTRATION_DOWN_EVENT,
|
|
851
|
+
};
|
|
852
|
+
log.info(`Registration down received - trackingId: ${event?.trackingId ?? 'unknown'}, eventId: ${event?.eventId ?? 'unknown'}`, loggerContext);
|
|
853
|
+
const [activeCall] = Object.values(this.callManager.getActiveCalls());
|
|
854
|
+
activeCall?.end();
|
|
855
|
+
await this.performRegistrationDownCleanup(METHODS.HANDLE_REGISTRATION_DOWN_EVENT);
|
|
856
|
+
}
|
|
857
|
+
async performRegistrationDownCleanup(caller) {
|
|
858
|
+
const loggerContext = {
|
|
859
|
+
file: REGISTRATION_FILE,
|
|
860
|
+
method: METHODS.HANDLE_REGISTRATION_DOWN_EVENT,
|
|
861
|
+
};
|
|
862
|
+
log.info(`[${caller}] : Running registration-down cleanup`, loggerContext);
|
|
863
|
+
await this.mutex.runExclusive(async () => {
|
|
864
|
+
this.clearFailbackTimer();
|
|
865
|
+
this.clearKeepaliveTimer();
|
|
866
|
+
this.reconnectPending = false;
|
|
867
|
+
this.scheduled429Retry = false;
|
|
868
|
+
this.failoverImmediately = false;
|
|
869
|
+
this.retryAfter = undefined;
|
|
870
|
+
this.registerRetry = false;
|
|
871
|
+
this.clearFailoverState();
|
|
872
|
+
this.setStatus(RegistrationStatus.INACTIVE);
|
|
873
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
874
|
+
try {
|
|
875
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
876
|
+
code: 3050,
|
|
877
|
+
reason: 'done (permanent)',
|
|
878
|
+
});
|
|
879
|
+
log.log('Mobius socket disconnect complete after registration-down', loggerContext);
|
|
880
|
+
}
|
|
881
|
+
catch (err) {
|
|
882
|
+
log.warn(`Mobius socket disconnect failed after registration-down: ${String(err)}`, loggerContext);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
this.lineEmitter(LINE_EVENTS.UNREGISTERED);
|
|
886
|
+
});
|
|
887
|
+
}
|
|
704
888
|
}
|
|
705
889
|
export const createRegistration = (webex, serviceData, mutex, lineEmitter, logLevel, jwe) => new Registration(webex, serviceData, mutex, lineEmitter, logLevel, jwe);
|