@koi-design/callkit 2.0.0-beta.6 → 2.0.0-beta.7

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.mjs CHANGED
@@ -442,7 +442,7 @@ var Call = class {
442
442
  constructor(callKit) {
443
443
  this.callKit = callKit;
444
444
  }
445
- async callStart() {
445
+ async callStart(params) {
446
446
  if (!this.callKit.config.check())
447
447
  return;
448
448
  this.callKit.logger.info("callStart", {
@@ -461,19 +461,15 @@ var Call = class {
461
461
  return;
462
462
  }
463
463
  this.callKit.connect.call(async (user) => {
464
- let queryTrain = {};
464
+ const queryTrain = {
465
+ ...params?.extra || {},
466
+ agentId: user.agentId,
467
+ sourceType: user.sourceType
468
+ };
465
469
  if (user.sourceType === CallSourceType.phoneNum) {
466
- queryTrain = {
467
- agentId: user.agentId,
468
- phoneNum: user.extno,
469
- sourceType: user.sourceType
470
- };
470
+ queryTrain.phoneNum = user.extno;
471
471
  } else if (user.sourceType === CallSourceType.workOrderId) {
472
- queryTrain = {
473
- agentId: user.agentId,
474
- workOrderId: user.workOrderId,
475
- sourceType: user.sourceType
476
- };
472
+ queryTrain.workOrderId = user.workOrderId;
477
473
  }
478
474
  this.callKit.socket.send(SocketSendEvent.CALL, queryTrain);
479
475
  });
@@ -621,7 +617,7 @@ var Config = class {
621
617
  }
622
618
  });
623
619
  };
624
- reset = () => {
620
+ reset = async () => {
625
621
  if (this.isLogin()) {
626
622
  this.config.userInfo = {
627
623
  wsUrl: "",
@@ -909,7 +905,7 @@ var Connect = class {
909
905
  ...reconnect
910
906
  };
911
907
  }
912
- reset() {
908
+ async reset() {
913
909
  if (this.isHolding()) {
914
910
  this.setHold(false);
915
911
  }
@@ -941,7 +937,6 @@ var Connect = class {
941
937
  });
942
938
  }
943
939
  }
944
- this.callKit.config.reset();
945
940
  this.setConnectStatus(CallStatus.init);
946
941
  this.clearObserveOptionsHeartbeatInterval();
947
942
  }
@@ -2066,6 +2061,7 @@ var Socket = class {
2066
2061
  data: data.data
2067
2062
  }
2068
2063
  });
2064
+ this.socketError = true;
2069
2065
  this.callKit.reset();
2070
2066
  }
2071
2067
  if (data.event === SocketReceiveEvent.AGENT_NO_ANSWER) {
@@ -2360,7 +2356,7 @@ var CallKit = class {
2360
2356
  });
2361
2357
  }
2362
2358
  }
2363
- async logout() {
2359
+ async logout({ isReset = true } = { isReset: true }) {
2364
2360
  if (!this.config.check())
2365
2361
  return;
2366
2362
  const { userInfo } = this.config.getConfig();
@@ -2383,10 +2379,9 @@ var CallKit = class {
2383
2379
  });
2384
2380
  }
2385
2381
  }
2386
- await this.hangup();
2387
- this.connect.reset();
2388
- this.socket.reset();
2389
- this.config.reset();
2382
+ if (isReset) {
2383
+ await this.reset();
2384
+ }
2390
2385
  this.trigger(KitEvent.KIT_LOGIN_CHANGE, false);
2391
2386
  }
2392
2387
  async call(extno = "", options = {
@@ -2420,7 +2415,7 @@ var CallKit = class {
2420
2415
  options
2421
2416
  }
2422
2417
  });
2423
- this.callCenter.callStart();
2418
+ this.callCenter.callStart(options);
2424
2419
  }
2425
2420
  async refer(uri, options) {
2426
2421
  if (!this.config.check())
@@ -2537,7 +2532,15 @@ var CallKit = class {
2537
2532
  connectStatus: this.connect.connectStatus
2538
2533
  }
2539
2534
  });
2540
- this.connect.reset();
2535
+ if (this.connect.isCalling()) {
2536
+ await this.hangup();
2537
+ }
2538
+ await this.connect.reset();
2539
+ if (this.config.isLogin()) {
2540
+ await this.logout({ isReset: false });
2541
+ }
2542
+ await this.config.reset();
2543
+ await this.socket.reset();
2541
2544
  }
2542
2545
  on(event, callback) {
2543
2546
  this.listener.push({