@koi-design/callkit 2.0.0-beta.1 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +12 -4
- package/dist/index.global.js +50 -282
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +38 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
|
@@ -267,7 +267,7 @@ declare class Socket {
|
|
|
267
267
|
* 重置 socket 连接和所有状态
|
|
268
268
|
* @param isWaitConfirm Whether need to wait for close confirmation
|
|
269
269
|
*/
|
|
270
|
-
reset(
|
|
270
|
+
reset(): Promise<void>;
|
|
271
271
|
private attemptReconnect;
|
|
272
272
|
}
|
|
273
273
|
|
|
@@ -355,7 +355,7 @@ declare class Connect {
|
|
|
355
355
|
/**
|
|
356
356
|
* Whether registered
|
|
357
357
|
*/
|
|
358
|
-
|
|
358
|
+
private isRegister;
|
|
359
359
|
constructor(callKit: CallKit);
|
|
360
360
|
reset(): void;
|
|
361
361
|
private getAduioReference;
|
|
@@ -375,9 +375,17 @@ declare class Connect {
|
|
|
375
375
|
*/
|
|
376
376
|
isRinging(): boolean;
|
|
377
377
|
/**
|
|
378
|
-
*
|
|
378
|
+
* isHolding
|
|
379
379
|
*/
|
|
380
380
|
isHolding(): boolean;
|
|
381
|
+
/**
|
|
382
|
+
* isRegistered
|
|
383
|
+
*/
|
|
384
|
+
isRegistered(): boolean;
|
|
385
|
+
/**
|
|
386
|
+
* isMute
|
|
387
|
+
*/
|
|
388
|
+
isMuted(): boolean;
|
|
381
389
|
/**
|
|
382
390
|
* Call ended, call not started
|
|
383
391
|
* @returns
|
|
@@ -473,7 +481,7 @@ declare class CallKit {
|
|
|
473
481
|
* set userstatus
|
|
474
482
|
* @param status
|
|
475
483
|
*/
|
|
476
|
-
setUserStatus(status: number): void
|
|
484
|
+
setUserStatus(status: number): Promise<void>;
|
|
477
485
|
reset(): Promise<void>;
|
|
478
486
|
on(event: kitEventType, callback: (...args: any[]) => void): void;
|
|
479
487
|
off(event: kitEventType, callback?: (...args: any[]) => void): void;
|
package/dist/index.global.js
CHANGED
|
@@ -1083,16 +1083,16 @@ var WebCall = (() => {
|
|
|
1083
1083
|
createDebug.names = [];
|
|
1084
1084
|
createDebug.skips = [];
|
|
1085
1085
|
createDebug.formatters = {};
|
|
1086
|
-
function selectColor(
|
|
1086
|
+
function selectColor(namespace) {
|
|
1087
1087
|
let hash = 0;
|
|
1088
|
-
for (let i = 0; i <
|
|
1089
|
-
hash = (hash << 5) - hash +
|
|
1088
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
1089
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
1090
1090
|
hash |= 0;
|
|
1091
1091
|
}
|
|
1092
1092
|
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
1093
1093
|
}
|
|
1094
1094
|
createDebug.selectColor = selectColor;
|
|
1095
|
-
function createDebug(
|
|
1095
|
+
function createDebug(namespace) {
|
|
1096
1096
|
let prevTime;
|
|
1097
1097
|
let enableOverride = null;
|
|
1098
1098
|
let namespacesCache;
|
|
@@ -1131,9 +1131,9 @@ var WebCall = (() => {
|
|
|
1131
1131
|
const logFn = self.log || createDebug.log;
|
|
1132
1132
|
logFn.apply(self, args);
|
|
1133
1133
|
}
|
|
1134
|
-
debug.namespace =
|
|
1134
|
+
debug.namespace = namespace;
|
|
1135
1135
|
debug.useColors = createDebug.useColors();
|
|
1136
|
-
debug.color = createDebug.selectColor(
|
|
1136
|
+
debug.color = createDebug.selectColor(namespace);
|
|
1137
1137
|
debug.extend = extend;
|
|
1138
1138
|
debug.destroy = createDebug.destroy;
|
|
1139
1139
|
Object.defineProperty(debug, "enabled", {
|
|
@@ -1145,7 +1145,7 @@ var WebCall = (() => {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
if (namespacesCache !== createDebug.namespaces) {
|
|
1147
1147
|
namespacesCache = createDebug.namespaces;
|
|
1148
|
-
enabledCache = createDebug.enabled(
|
|
1148
|
+
enabledCache = createDebug.enabled(namespace);
|
|
1149
1149
|
}
|
|
1150
1150
|
return enabledCache;
|
|
1151
1151
|
},
|
|
@@ -1158,8 +1158,8 @@ var WebCall = (() => {
|
|
|
1158
1158
|
}
|
|
1159
1159
|
return debug;
|
|
1160
1160
|
}
|
|
1161
|
-
function extend(
|
|
1162
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) +
|
|
1161
|
+
function extend(namespace, delimiter) {
|
|
1162
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
1163
1163
|
newDebug.log = this.log;
|
|
1164
1164
|
return newDebug;
|
|
1165
1165
|
}
|
|
@@ -1208,7 +1208,7 @@ var WebCall = (() => {
|
|
|
1208
1208
|
function disable() {
|
|
1209
1209
|
const namespaces = [
|
|
1210
1210
|
...createDebug.names,
|
|
1211
|
-
...createDebug.skips.map((
|
|
1211
|
+
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
1212
1212
|
].join(",");
|
|
1213
1213
|
createDebug.enable("");
|
|
1214
1214
|
return namespaces;
|
|
@@ -3161,47 +3161,6 @@ var WebCall = (() => {
|
|
|
3161
3161
|
}
|
|
3162
3162
|
});
|
|
3163
3163
|
|
|
3164
|
-
// node_modules/.pnpm/is-retry-allowed@2.2.0/node_modules/is-retry-allowed/index.js
|
|
3165
|
-
var require_is_retry_allowed = __commonJS({
|
|
3166
|
-
"node_modules/.pnpm/is-retry-allowed@2.2.0/node_modules/is-retry-allowed/index.js"(exports, module) {
|
|
3167
|
-
"use strict";
|
|
3168
|
-
var denyList = /* @__PURE__ */ new Set([
|
|
3169
|
-
"ENOTFOUND",
|
|
3170
|
-
"ENETUNREACH",
|
|
3171
|
-
// SSL errors from https://github.com/nodejs/node/blob/fc8e3e2cdc521978351de257030db0076d79e0ab/src/crypto/crypto_common.cc#L301-L328
|
|
3172
|
-
"UNABLE_TO_GET_ISSUER_CERT",
|
|
3173
|
-
"UNABLE_TO_GET_CRL",
|
|
3174
|
-
"UNABLE_TO_DECRYPT_CERT_SIGNATURE",
|
|
3175
|
-
"UNABLE_TO_DECRYPT_CRL_SIGNATURE",
|
|
3176
|
-
"UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY",
|
|
3177
|
-
"CERT_SIGNATURE_FAILURE",
|
|
3178
|
-
"CRL_SIGNATURE_FAILURE",
|
|
3179
|
-
"CERT_NOT_YET_VALID",
|
|
3180
|
-
"CERT_HAS_EXPIRED",
|
|
3181
|
-
"CRL_NOT_YET_VALID",
|
|
3182
|
-
"CRL_HAS_EXPIRED",
|
|
3183
|
-
"ERROR_IN_CERT_NOT_BEFORE_FIELD",
|
|
3184
|
-
"ERROR_IN_CERT_NOT_AFTER_FIELD",
|
|
3185
|
-
"ERROR_IN_CRL_LAST_UPDATE_FIELD",
|
|
3186
|
-
"ERROR_IN_CRL_NEXT_UPDATE_FIELD",
|
|
3187
|
-
"OUT_OF_MEM",
|
|
3188
|
-
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
3189
|
-
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
3190
|
-
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
3191
|
-
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
3192
|
-
"CERT_CHAIN_TOO_LONG",
|
|
3193
|
-
"CERT_REVOKED",
|
|
3194
|
-
"INVALID_CA",
|
|
3195
|
-
"PATH_LENGTH_EXCEEDED",
|
|
3196
|
-
"INVALID_PURPOSE",
|
|
3197
|
-
"CERT_UNTRUSTED",
|
|
3198
|
-
"CERT_REJECTED",
|
|
3199
|
-
"HOSTNAME_MISMATCH"
|
|
3200
|
-
]);
|
|
3201
|
-
module.exports = (error) => !denyList.has(error && error.code);
|
|
3202
|
-
}
|
|
3203
|
-
});
|
|
3204
|
-
|
|
3205
3164
|
// node_modules/.pnpm/json-stringify-safe@5.0.1/node_modules/json-stringify-safe/stringify.js
|
|
3206
3165
|
var require_stringify = __commonJS({
|
|
3207
3166
|
"node_modules/.pnpm/json-stringify-safe@5.0.1/node_modules/json-stringify-safe/stringify.js"(exports, module) {
|
|
@@ -3242,189 +3201,6 @@ var WebCall = (() => {
|
|
|
3242
3201
|
|
|
3243
3202
|
// package/axios.ts
|
|
3244
3203
|
var import_axios = __toESM(require_axios2());
|
|
3245
|
-
|
|
3246
|
-
// node_modules/.pnpm/axios-retry@4.5.0_axios@0.26.1/node_modules/axios-retry/dist/esm/index.js
|
|
3247
|
-
var import_is_retry_allowed = __toESM(require_is_retry_allowed(), 1);
|
|
3248
|
-
var namespace = "axios-retry";
|
|
3249
|
-
function isNetworkError(error) {
|
|
3250
|
-
const CODE_EXCLUDE_LIST = ["ERR_CANCELED", "ECONNABORTED"];
|
|
3251
|
-
if (error.response) {
|
|
3252
|
-
return false;
|
|
3253
|
-
}
|
|
3254
|
-
if (!error.code) {
|
|
3255
|
-
return false;
|
|
3256
|
-
}
|
|
3257
|
-
if (CODE_EXCLUDE_LIST.includes(error.code)) {
|
|
3258
|
-
return false;
|
|
3259
|
-
}
|
|
3260
|
-
return (0, import_is_retry_allowed.default)(error);
|
|
3261
|
-
}
|
|
3262
|
-
var SAFE_HTTP_METHODS = ["get", "head", "options"];
|
|
3263
|
-
var IDEMPOTENT_HTTP_METHODS = SAFE_HTTP_METHODS.concat(["put", "delete"]);
|
|
3264
|
-
function isRetryableError(error) {
|
|
3265
|
-
return error.code !== "ECONNABORTED" && (!error.response || error.response.status === 429 || error.response.status >= 500 && error.response.status <= 599);
|
|
3266
|
-
}
|
|
3267
|
-
function isSafeRequestError(error) {
|
|
3268
|
-
if (!error.config?.method) {
|
|
3269
|
-
return false;
|
|
3270
|
-
}
|
|
3271
|
-
return isRetryableError(error) && SAFE_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
3272
|
-
}
|
|
3273
|
-
function isIdempotentRequestError(error) {
|
|
3274
|
-
if (!error.config?.method) {
|
|
3275
|
-
return false;
|
|
3276
|
-
}
|
|
3277
|
-
return isRetryableError(error) && IDEMPOTENT_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
3278
|
-
}
|
|
3279
|
-
function isNetworkOrIdempotentRequestError(error) {
|
|
3280
|
-
return isNetworkError(error) || isIdempotentRequestError(error);
|
|
3281
|
-
}
|
|
3282
|
-
function retryAfter(error = void 0) {
|
|
3283
|
-
const retryAfterHeader = error?.response?.headers["retry-after"];
|
|
3284
|
-
if (!retryAfterHeader) {
|
|
3285
|
-
return 0;
|
|
3286
|
-
}
|
|
3287
|
-
let retryAfterMs = (Number(retryAfterHeader) || 0) * 1e3;
|
|
3288
|
-
if (retryAfterMs === 0) {
|
|
3289
|
-
retryAfterMs = (new Date(retryAfterHeader).valueOf() || 0) - Date.now();
|
|
3290
|
-
}
|
|
3291
|
-
return Math.max(0, retryAfterMs);
|
|
3292
|
-
}
|
|
3293
|
-
function noDelay(_retryNumber = 0, error = void 0) {
|
|
3294
|
-
return Math.max(0, retryAfter(error));
|
|
3295
|
-
}
|
|
3296
|
-
function exponentialDelay(retryNumber = 0, error = void 0, delayFactor = 100) {
|
|
3297
|
-
const calculatedDelay = 2 ** retryNumber * delayFactor;
|
|
3298
|
-
const delay = Math.max(calculatedDelay, retryAfter(error));
|
|
3299
|
-
const randomSum = delay * 0.2 * Math.random();
|
|
3300
|
-
return delay + randomSum;
|
|
3301
|
-
}
|
|
3302
|
-
function linearDelay(delayFactor = 100) {
|
|
3303
|
-
return (retryNumber = 0, error = void 0) => {
|
|
3304
|
-
const delay = retryNumber * delayFactor;
|
|
3305
|
-
return Math.max(delay, retryAfter(error));
|
|
3306
|
-
};
|
|
3307
|
-
}
|
|
3308
|
-
var DEFAULT_OPTIONS = {
|
|
3309
|
-
retries: 3,
|
|
3310
|
-
retryCondition: isNetworkOrIdempotentRequestError,
|
|
3311
|
-
retryDelay: noDelay,
|
|
3312
|
-
shouldResetTimeout: false,
|
|
3313
|
-
onRetry: () => {
|
|
3314
|
-
},
|
|
3315
|
-
onMaxRetryTimesExceeded: () => {
|
|
3316
|
-
},
|
|
3317
|
-
validateResponse: null
|
|
3318
|
-
};
|
|
3319
|
-
function getRequestOptions(config, defaultOptions) {
|
|
3320
|
-
return { ...DEFAULT_OPTIONS, ...defaultOptions, ...config[namespace] };
|
|
3321
|
-
}
|
|
3322
|
-
function setCurrentState(config, defaultOptions, resetLastRequestTime = false) {
|
|
3323
|
-
const currentState = getRequestOptions(config, defaultOptions || {});
|
|
3324
|
-
currentState.retryCount = currentState.retryCount || 0;
|
|
3325
|
-
if (!currentState.lastRequestTime || resetLastRequestTime) {
|
|
3326
|
-
currentState.lastRequestTime = Date.now();
|
|
3327
|
-
}
|
|
3328
|
-
config[namespace] = currentState;
|
|
3329
|
-
return currentState;
|
|
3330
|
-
}
|
|
3331
|
-
function fixConfig(axiosInstance, config) {
|
|
3332
|
-
if (axiosInstance.defaults.agent === config.agent) {
|
|
3333
|
-
delete config.agent;
|
|
3334
|
-
}
|
|
3335
|
-
if (axiosInstance.defaults.httpAgent === config.httpAgent) {
|
|
3336
|
-
delete config.httpAgent;
|
|
3337
|
-
}
|
|
3338
|
-
if (axiosInstance.defaults.httpsAgent === config.httpsAgent) {
|
|
3339
|
-
delete config.httpsAgent;
|
|
3340
|
-
}
|
|
3341
|
-
}
|
|
3342
|
-
async function shouldRetry(currentState, error) {
|
|
3343
|
-
const { retries, retryCondition } = currentState;
|
|
3344
|
-
const shouldRetryOrPromise = (currentState.retryCount || 0) < retries && retryCondition(error);
|
|
3345
|
-
if (typeof shouldRetryOrPromise === "object") {
|
|
3346
|
-
try {
|
|
3347
|
-
const shouldRetryPromiseResult = await shouldRetryOrPromise;
|
|
3348
|
-
return shouldRetryPromiseResult !== false;
|
|
3349
|
-
} catch (_err) {
|
|
3350
|
-
return false;
|
|
3351
|
-
}
|
|
3352
|
-
}
|
|
3353
|
-
return shouldRetryOrPromise;
|
|
3354
|
-
}
|
|
3355
|
-
async function handleRetry(axiosInstance, currentState, error, config) {
|
|
3356
|
-
currentState.retryCount += 1;
|
|
3357
|
-
const { retryDelay, shouldResetTimeout, onRetry } = currentState;
|
|
3358
|
-
const delay = retryDelay(currentState.retryCount, error);
|
|
3359
|
-
fixConfig(axiosInstance, config);
|
|
3360
|
-
if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) {
|
|
3361
|
-
const lastRequestDuration = Date.now() - currentState.lastRequestTime;
|
|
3362
|
-
const timeout = config.timeout - lastRequestDuration - delay;
|
|
3363
|
-
if (timeout <= 0) {
|
|
3364
|
-
return Promise.reject(error);
|
|
3365
|
-
}
|
|
3366
|
-
config.timeout = timeout;
|
|
3367
|
-
}
|
|
3368
|
-
config.transformRequest = [(data) => data];
|
|
3369
|
-
await onRetry(currentState.retryCount, error, config);
|
|
3370
|
-
if (config.signal?.aborted) {
|
|
3371
|
-
return Promise.resolve(axiosInstance(config));
|
|
3372
|
-
}
|
|
3373
|
-
return new Promise((resolve) => {
|
|
3374
|
-
const abortListener = () => {
|
|
3375
|
-
clearTimeout(timeout);
|
|
3376
|
-
resolve(axiosInstance(config));
|
|
3377
|
-
};
|
|
3378
|
-
const timeout = setTimeout(() => {
|
|
3379
|
-
resolve(axiosInstance(config));
|
|
3380
|
-
if (config.signal?.removeEventListener) {
|
|
3381
|
-
config.signal.removeEventListener("abort", abortListener);
|
|
3382
|
-
}
|
|
3383
|
-
}, delay);
|
|
3384
|
-
if (config.signal?.addEventListener) {
|
|
3385
|
-
config.signal.addEventListener("abort", abortListener, { once: true });
|
|
3386
|
-
}
|
|
3387
|
-
});
|
|
3388
|
-
}
|
|
3389
|
-
async function handleMaxRetryTimesExceeded(currentState, error) {
|
|
3390
|
-
if (currentState.retryCount >= currentState.retries)
|
|
3391
|
-
await currentState.onMaxRetryTimesExceeded(error, currentState.retryCount);
|
|
3392
|
-
}
|
|
3393
|
-
var axiosRetry = (axiosInstance, defaultOptions) => {
|
|
3394
|
-
const requestInterceptorId = axiosInstance.interceptors.request.use((config) => {
|
|
3395
|
-
setCurrentState(config, defaultOptions, true);
|
|
3396
|
-
if (config[namespace]?.validateResponse) {
|
|
3397
|
-
config.validateStatus = () => false;
|
|
3398
|
-
}
|
|
3399
|
-
return config;
|
|
3400
|
-
});
|
|
3401
|
-
const responseInterceptorId = axiosInstance.interceptors.response.use(null, async (error) => {
|
|
3402
|
-
const { config } = error;
|
|
3403
|
-
if (!config) {
|
|
3404
|
-
return Promise.reject(error);
|
|
3405
|
-
}
|
|
3406
|
-
const currentState = setCurrentState(config, defaultOptions);
|
|
3407
|
-
if (error.response && currentState.validateResponse?.(error.response)) {
|
|
3408
|
-
return error.response;
|
|
3409
|
-
}
|
|
3410
|
-
if (await shouldRetry(currentState, error)) {
|
|
3411
|
-
return handleRetry(axiosInstance, currentState, error, config);
|
|
3412
|
-
}
|
|
3413
|
-
await handleMaxRetryTimesExceeded(currentState, error);
|
|
3414
|
-
return Promise.reject(error);
|
|
3415
|
-
});
|
|
3416
|
-
return { requestInterceptorId, responseInterceptorId };
|
|
3417
|
-
};
|
|
3418
|
-
axiosRetry.isNetworkError = isNetworkError;
|
|
3419
|
-
axiosRetry.isSafeRequestError = isSafeRequestError;
|
|
3420
|
-
axiosRetry.isIdempotentRequestError = isIdempotentRequestError;
|
|
3421
|
-
axiosRetry.isNetworkOrIdempotentRequestError = isNetworkOrIdempotentRequestError;
|
|
3422
|
-
axiosRetry.exponentialDelay = exponentialDelay;
|
|
3423
|
-
axiosRetry.linearDelay = linearDelay;
|
|
3424
|
-
axiosRetry.isRetryableError = isRetryableError;
|
|
3425
|
-
var esm_default = axiosRetry;
|
|
3426
|
-
|
|
3427
|
-
// package/axios.ts
|
|
3428
3204
|
var instance = import_axios.default.create({
|
|
3429
3205
|
headers: {
|
|
3430
3206
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -3435,23 +3211,6 @@ var WebCall = (() => {
|
|
|
3435
3211
|
(response) => response.data,
|
|
3436
3212
|
(error) => Promise.reject(error)
|
|
3437
3213
|
);
|
|
3438
|
-
esm_default(instance, {
|
|
3439
|
-
retries: 3,
|
|
3440
|
-
// Maximum number of retries, default is 3
|
|
3441
|
-
retryDelay: (retryCount, error) => {
|
|
3442
|
-
console.log(
|
|
3443
|
-
`AJAX Retrying attempt ${retryCount}, error: ${error?.message}`
|
|
3444
|
-
);
|
|
3445
|
-
return retryCount * 1e3;
|
|
3446
|
-
},
|
|
3447
|
-
retryCondition: (error) => {
|
|
3448
|
-
if (!error.response)
|
|
3449
|
-
return true;
|
|
3450
|
-
return error.response.status < 200 || error.response.status >= 300;
|
|
3451
|
-
},
|
|
3452
|
-
shouldResetTimeout: true
|
|
3453
|
-
// Whether to reset axios timeout on retry
|
|
3454
|
-
});
|
|
3455
3214
|
var request = (config) => instance.request(config);
|
|
3456
3215
|
var axios_default = request;
|
|
3457
3216
|
|
|
@@ -13204,8 +12963,8 @@ var WebCall = (() => {
|
|
|
13204
12963
|
this.logger.warn(msg);
|
|
13205
12964
|
return;
|
|
13206
12965
|
};
|
|
13207
|
-
const
|
|
13208
|
-
const extraHeaders = [`Retry-After: ${
|
|
12966
|
+
const retryAfter = Math.floor(Math.random() * 10) + 1;
|
|
12967
|
+
const extraHeaders = [`Retry-After: ${retryAfter}`];
|
|
13209
12968
|
if (this.ackProcessing) {
|
|
13210
12969
|
this.core.replyStateless(message, { statusCode: 500, extraHeaders });
|
|
13211
12970
|
warning();
|
|
@@ -18673,7 +18432,7 @@ var WebCall = (() => {
|
|
|
18673
18432
|
/**
|
|
18674
18433
|
* Whether registered
|
|
18675
18434
|
*/
|
|
18676
|
-
|
|
18435
|
+
isRegister = false;
|
|
18677
18436
|
constructor(callKit) {
|
|
18678
18437
|
this.callKit = callKit;
|
|
18679
18438
|
const { reconnect = {} } = this.callKit.config.getConfig();
|
|
@@ -18713,6 +18472,7 @@ var WebCall = (() => {
|
|
|
18713
18472
|
});
|
|
18714
18473
|
}
|
|
18715
18474
|
}
|
|
18475
|
+
this.callKit.config.reset();
|
|
18716
18476
|
this.setConnectStatus(CallStatus.init);
|
|
18717
18477
|
this.clearObserveOptionsHeartbeatInterval();
|
|
18718
18478
|
}
|
|
@@ -18755,11 +18515,23 @@ var WebCall = (() => {
|
|
|
18755
18515
|
return this.connectStatus === CallStatus.ringing;
|
|
18756
18516
|
}
|
|
18757
18517
|
/**
|
|
18758
|
-
*
|
|
18518
|
+
* isHolding
|
|
18759
18519
|
*/
|
|
18760
18520
|
isHolding() {
|
|
18761
18521
|
return this.connectStatus === CallStatus.holding;
|
|
18762
18522
|
}
|
|
18523
|
+
/**
|
|
18524
|
+
* isRegistered
|
|
18525
|
+
*/
|
|
18526
|
+
isRegistered() {
|
|
18527
|
+
return this.isRegister;
|
|
18528
|
+
}
|
|
18529
|
+
/**
|
|
18530
|
+
* isMute
|
|
18531
|
+
*/
|
|
18532
|
+
isMuted() {
|
|
18533
|
+
return this.isMute;
|
|
18534
|
+
}
|
|
18763
18535
|
/**
|
|
18764
18536
|
* Call ended, call not started
|
|
18765
18537
|
* @returns
|
|
@@ -18788,7 +18560,7 @@ var WebCall = (() => {
|
|
|
18788
18560
|
}
|
|
18789
18561
|
async register() {
|
|
18790
18562
|
if (this.connectStatus !== CallStatus.init) {
|
|
18791
|
-
if (this.isRegistered) {
|
|
18563
|
+
if (this.isRegistered()) {
|
|
18792
18564
|
this.callKit.logger.warn("connectStatus is registered", {
|
|
18793
18565
|
caller: "Connect.register",
|
|
18794
18566
|
content: {
|
|
@@ -18924,14 +18696,14 @@ var WebCall = (() => {
|
|
|
18924
18696
|
type: "SIP",
|
|
18925
18697
|
content: {
|
|
18926
18698
|
registererState: state,
|
|
18927
|
-
isRegistered: this.isRegistered
|
|
18699
|
+
isRegistered: this.isRegistered()
|
|
18928
18700
|
}
|
|
18929
18701
|
});
|
|
18930
18702
|
this.setRegister(false);
|
|
18931
18703
|
this.setConnectStatus(CallStatus.init);
|
|
18932
18704
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18933
18705
|
registererState: state,
|
|
18934
|
-
isRegistered: this.isRegistered
|
|
18706
|
+
isRegistered: this.isRegistered()
|
|
18935
18707
|
});
|
|
18936
18708
|
break;
|
|
18937
18709
|
case RegistererState.Registered:
|
|
@@ -18940,13 +18712,13 @@ var WebCall = (() => {
|
|
|
18940
18712
|
type: "SIP",
|
|
18941
18713
|
content: {
|
|
18942
18714
|
registererState: state,
|
|
18943
|
-
isRegistered: this.isRegistered
|
|
18715
|
+
isRegistered: this.isRegistered()
|
|
18944
18716
|
}
|
|
18945
18717
|
});
|
|
18946
18718
|
this.setRegister(true);
|
|
18947
18719
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18948
18720
|
registererState: state,
|
|
18949
|
-
isRegistered: this.isRegistered
|
|
18721
|
+
isRegistered: this.isRegistered()
|
|
18950
18722
|
});
|
|
18951
18723
|
break;
|
|
18952
18724
|
case RegistererState.Terminated:
|
|
@@ -18955,13 +18727,13 @@ var WebCall = (() => {
|
|
|
18955
18727
|
type: "SIP",
|
|
18956
18728
|
content: {
|
|
18957
18729
|
registererState: state,
|
|
18958
|
-
isRegistered: this.isRegistered
|
|
18730
|
+
isRegistered: this.isRegistered()
|
|
18959
18731
|
}
|
|
18960
18732
|
});
|
|
18961
18733
|
this.setRegister(false);
|
|
18962
18734
|
this.setConnectStatus(CallStatus.init);
|
|
18963
18735
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18964
|
-
isRegistered: this.isRegistered,
|
|
18736
|
+
isRegistered: this.isRegistered(),
|
|
18965
18737
|
registererState: state
|
|
18966
18738
|
});
|
|
18967
18739
|
break;
|
|
@@ -18970,14 +18742,14 @@ var WebCall = (() => {
|
|
|
18970
18742
|
caller: "Connect.register.registererStateChange",
|
|
18971
18743
|
type: "SIP",
|
|
18972
18744
|
content: {
|
|
18973
|
-
isRegistered: this.isRegistered,
|
|
18745
|
+
isRegistered: this.isRegistered(),
|
|
18974
18746
|
registererState: state
|
|
18975
18747
|
}
|
|
18976
18748
|
});
|
|
18977
18749
|
this.setRegister(false);
|
|
18978
18750
|
this.setConnectStatus(CallStatus.init);
|
|
18979
18751
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18980
|
-
isRegistered: this.isRegistered,
|
|
18752
|
+
isRegistered: this.isRegistered(),
|
|
18981
18753
|
registererState: state
|
|
18982
18754
|
});
|
|
18983
18755
|
break;
|
|
@@ -18992,7 +18764,7 @@ var WebCall = (() => {
|
|
|
18992
18764
|
caller: "Connect.register.onInvite",
|
|
18993
18765
|
content: {
|
|
18994
18766
|
invite,
|
|
18995
|
-
isRegistered: this.isRegistered
|
|
18767
|
+
isRegistered: this.isRegistered()
|
|
18996
18768
|
}
|
|
18997
18769
|
});
|
|
18998
18770
|
this.currentSession = invite;
|
|
@@ -19012,7 +18784,7 @@ var WebCall = (() => {
|
|
|
19012
18784
|
this.setConnectStatus(CallStatus.ringing);
|
|
19013
18785
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
19014
18786
|
sessionState: state,
|
|
19015
|
-
isRegistered: this.isRegistered
|
|
18787
|
+
isRegistered: this.isRegistered()
|
|
19016
18788
|
});
|
|
19017
18789
|
break;
|
|
19018
18790
|
case SessionState2.Established:
|
|
@@ -19026,14 +18798,14 @@ var WebCall = (() => {
|
|
|
19026
18798
|
this.callKit.connect.setConnectStatus(CallStatus.calling);
|
|
19027
18799
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
19028
18800
|
sessionState: state,
|
|
19029
|
-
isRegistered: this.isRegistered
|
|
18801
|
+
isRegistered: this.isRegistered()
|
|
19030
18802
|
});
|
|
19031
18803
|
setupRemoteMedia(this.currentSession);
|
|
19032
18804
|
break;
|
|
19033
18805
|
case SessionState2.Terminating:
|
|
19034
18806
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
19035
18807
|
sessionState: state,
|
|
19036
|
-
isRegistered: this.isRegistered
|
|
18808
|
+
isRegistered: this.isRegistered()
|
|
19037
18809
|
});
|
|
19038
18810
|
break;
|
|
19039
18811
|
case SessionState2.Terminated:
|
|
@@ -19054,7 +18826,7 @@ var WebCall = (() => {
|
|
|
19054
18826
|
this.isUnprompted = false;
|
|
19055
18827
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
19056
18828
|
sessionState: state,
|
|
19057
|
-
isRegistered: this.isRegistered
|
|
18829
|
+
isRegistered: this.isRegistered()
|
|
19058
18830
|
});
|
|
19059
18831
|
break;
|
|
19060
18832
|
default:
|
|
@@ -19241,11 +19013,10 @@ var WebCall = (() => {
|
|
|
19241
19013
|
caller: "Connect.unregister",
|
|
19242
19014
|
type: "SIP",
|
|
19243
19015
|
content: {
|
|
19244
|
-
isRegistered: this.isRegistered
|
|
19245
|
-
registerer: this.registerer
|
|
19016
|
+
isRegistered: this.isRegistered()
|
|
19246
19017
|
}
|
|
19247
19018
|
});
|
|
19248
|
-
if (!this.isRegistered || !this.registerer) {
|
|
19019
|
+
if (!this.isRegistered() || !this.registerer) {
|
|
19249
19020
|
this.callKit.logger.warn("No registerer to unregister.", {
|
|
19250
19021
|
caller: "Connect.unregister",
|
|
19251
19022
|
type: "SIP",
|
|
@@ -19275,7 +19046,7 @@ var WebCall = (() => {
|
|
|
19275
19046
|
}
|
|
19276
19047
|
});
|
|
19277
19048
|
this.isOutgoing = true;
|
|
19278
|
-
if (!this.isRegistered) {
|
|
19049
|
+
if (!this.isRegistered()) {
|
|
19279
19050
|
await this.register();
|
|
19280
19051
|
}
|
|
19281
19052
|
this.setConnectStatus(CallStatus.connecting);
|
|
@@ -19295,7 +19066,7 @@ var WebCall = (() => {
|
|
|
19295
19066
|
register
|
|
19296
19067
|
}
|
|
19297
19068
|
});
|
|
19298
|
-
this.
|
|
19069
|
+
this.isRegister = register;
|
|
19299
19070
|
this.callKit.trigger(KitEvent.KIT_REGISTER_CHANGE, register);
|
|
19300
19071
|
}
|
|
19301
19072
|
/**
|
|
@@ -19857,7 +19628,6 @@ var WebCall = (() => {
|
|
|
19857
19628
|
errCode: ErrorCode.SOCKET_CONNECT_ERROR
|
|
19858
19629
|
}
|
|
19859
19630
|
});
|
|
19860
|
-
this.callKit.config.reset();
|
|
19861
19631
|
this.callKit.reset();
|
|
19862
19632
|
return;
|
|
19863
19633
|
}
|
|
@@ -19964,7 +19734,7 @@ var WebCall = (() => {
|
|
|
19964
19734
|
* 重置 socket 连接和所有状态
|
|
19965
19735
|
* @param isWaitConfirm Whether need to wait for close confirmation
|
|
19966
19736
|
*/
|
|
19967
|
-
async reset(
|
|
19737
|
+
async reset() {
|
|
19968
19738
|
if (this.pingTimer) {
|
|
19969
19739
|
clearInterval(this.pingTimer);
|
|
19970
19740
|
this.pingTimer = void 0;
|
|
@@ -19976,9 +19746,7 @@ var WebCall = (() => {
|
|
|
19976
19746
|
this.callKit.logger.info("Closing socket connection", {
|
|
19977
19747
|
caller: "Socket.reset",
|
|
19978
19748
|
type: "INCALL",
|
|
19979
|
-
content: {
|
|
19980
|
-
isWaitConfirm
|
|
19981
|
-
}
|
|
19749
|
+
content: {}
|
|
19982
19750
|
});
|
|
19983
19751
|
this.ws.close();
|
|
19984
19752
|
this.isConnected = false;
|
|
@@ -20150,8 +19918,8 @@ var WebCall = (() => {
|
|
|
20150
19918
|
}
|
|
20151
19919
|
}
|
|
20152
19920
|
await this.hangup();
|
|
20153
|
-
this.socket.reset(false);
|
|
20154
19921
|
this.connect.reset();
|
|
19922
|
+
this.socket.reset();
|
|
20155
19923
|
this.config.reset();
|
|
20156
19924
|
this.trigger(KitEvent.KIT_LOGIN_CHANGE, false);
|
|
20157
19925
|
}
|
|
@@ -20267,9 +20035,9 @@ var WebCall = (() => {
|
|
|
20267
20035
|
* set userstatus
|
|
20268
20036
|
* @param status
|
|
20269
20037
|
*/
|
|
20270
|
-
setUserStatus(status) {
|
|
20038
|
+
async setUserStatus(status) {
|
|
20271
20039
|
const { agentId } = this.config.getConfig().userInfo;
|
|
20272
|
-
this.api.updateUserStatus({
|
|
20040
|
+
await this.api.updateUserStatus({
|
|
20273
20041
|
agentId,
|
|
20274
20042
|
status
|
|
20275
20043
|
});
|