@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.js CHANGED
@@ -475,7 +475,7 @@ var Call = class {
475
475
  constructor(callKit) {
476
476
  this.callKit = callKit;
477
477
  }
478
- async callStart() {
478
+ async callStart(params) {
479
479
  if (!this.callKit.config.check())
480
480
  return;
481
481
  this.callKit.logger.info("callStart", {
@@ -494,19 +494,15 @@ var Call = class {
494
494
  return;
495
495
  }
496
496
  this.callKit.connect.call(async (user) => {
497
- let queryTrain = {};
497
+ const queryTrain = {
498
+ ...params?.extra || {},
499
+ agentId: user.agentId,
500
+ sourceType: user.sourceType
501
+ };
498
502
  if (user.sourceType === CallSourceType.phoneNum) {
499
- queryTrain = {
500
- agentId: user.agentId,
501
- phoneNum: user.extno,
502
- sourceType: user.sourceType
503
- };
503
+ queryTrain.phoneNum = user.extno;
504
504
  } else if (user.sourceType === CallSourceType.workOrderId) {
505
- queryTrain = {
506
- agentId: user.agentId,
507
- workOrderId: user.workOrderId,
508
- sourceType: user.sourceType
509
- };
505
+ queryTrain.workOrderId = user.workOrderId;
510
506
  }
511
507
  this.callKit.socket.send(SocketSendEvent.CALL, queryTrain);
512
508
  });
@@ -654,7 +650,7 @@ var Config = class {
654
650
  }
655
651
  });
656
652
  };
657
- reset = () => {
653
+ reset = async () => {
658
654
  if (this.isLogin()) {
659
655
  this.config.userInfo = {
660
656
  wsUrl: "",
@@ -936,7 +932,7 @@ var Connect = class {
936
932
  ...reconnect
937
933
  };
938
934
  }
939
- reset() {
935
+ async reset() {
940
936
  if (this.isHolding()) {
941
937
  this.setHold(false);
942
938
  }
@@ -968,7 +964,6 @@ var Connect = class {
968
964
  });
969
965
  }
970
966
  }
971
- this.callKit.config.reset();
972
967
  this.setConnectStatus(CallStatus.init);
973
968
  this.clearObserveOptionsHeartbeatInterval();
974
969
  }
@@ -2093,6 +2088,7 @@ var Socket = class {
2093
2088
  data: data.data
2094
2089
  }
2095
2090
  });
2091
+ this.socketError = true;
2096
2092
  this.callKit.reset();
2097
2093
  }
2098
2094
  if (data.event === SocketReceiveEvent.AGENT_NO_ANSWER) {
@@ -2387,7 +2383,7 @@ var CallKit = class {
2387
2383
  });
2388
2384
  }
2389
2385
  }
2390
- async logout() {
2386
+ async logout({ isReset = true } = { isReset: true }) {
2391
2387
  if (!this.config.check())
2392
2388
  return;
2393
2389
  const { userInfo } = this.config.getConfig();
@@ -2410,10 +2406,9 @@ var CallKit = class {
2410
2406
  });
2411
2407
  }
2412
2408
  }
2413
- await this.hangup();
2414
- this.connect.reset();
2415
- this.socket.reset();
2416
- this.config.reset();
2409
+ if (isReset) {
2410
+ await this.reset();
2411
+ }
2417
2412
  this.trigger(KitEvent.KIT_LOGIN_CHANGE, false);
2418
2413
  }
2419
2414
  async call(extno = "", options = {
@@ -2447,7 +2442,7 @@ var CallKit = class {
2447
2442
  options
2448
2443
  }
2449
2444
  });
2450
- this.callCenter.callStart();
2445
+ this.callCenter.callStart(options);
2451
2446
  }
2452
2447
  async refer(uri, options) {
2453
2448
  if (!this.config.check())
@@ -2564,7 +2559,15 @@ var CallKit = class {
2564
2559
  connectStatus: this.connect.connectStatus
2565
2560
  }
2566
2561
  });
2567
- this.connect.reset();
2562
+ if (this.connect.isCalling()) {
2563
+ await this.hangup();
2564
+ }
2565
+ await this.connect.reset();
2566
+ if (this.config.isLogin()) {
2567
+ await this.logout({ isReset: false });
2568
+ }
2569
+ await this.config.reset();
2570
+ await this.socket.reset();
2568
2571
  }
2569
2572
  on(event, callback) {
2570
2573
  this.listener.push({