kucservice 1.4.7 → 1.4.9

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.
@@ -2078,7 +2078,7 @@ var es_json_stringify = __webpack_require__("e9c4");
2078
2078
  var EventTypes = ['open', 'close', 'message', 'error', 'reconnect'];
2079
2079
  var DEFAULT_CHECK_TIME = 30 * 1000; // 心跳检测的默认时间
2080
2080
 
2081
- var TIMEOUT = 40 * 1000; //重连延迟时间
2081
+ var TIMEOUT = 100; //重连延迟时间
2082
2082
 
2083
2083
  var DEFAULT_CHECK_COUNT = 10; // 心跳检测默认失败重连次数
2084
2084
 
@@ -2211,6 +2211,8 @@ var websocket_Socket = /*#__PURE__*/function (_WebSocket) {
2211
2211
  this.onclose = function (e) {
2212
2212
  var _this2 = this;
2213
2213
 
2214
+ console.error('webSocket关闭', e);
2215
+
2214
2216
  this._dep.notify('close', e); // 如果WebSocket是非正常关闭 则进行重连
2215
2217
 
2216
2218
 
@@ -11474,12 +11476,10 @@ var _phoneClientObj = /*#__PURE__*/new WeakMap();
11474
11476
 
11475
11477
  var common_request_wsClass = /*#__PURE__*/function () {
11476
11478
  function wsClass(config, _ref2) {
11477
- var _this = this;
11478
-
11479
- var _onOpen = _ref2.onOpen,
11480
- _onClose = _ref2.onClose,
11481
- _onMessage = _ref2.onMessage,
11482
- _onError = _ref2.onError,
11479
+ var onOpen = _ref2.onOpen,
11480
+ onClose = _ref2.onClose,
11481
+ onMessage = _ref2.onMessage,
11482
+ onError = _ref2.onError,
11483
11483
  initAction = _ref2.initAction;
11484
11484
 
11485
11485
  Object(classCallCheck["a" /* default */])(this, wsClass);
@@ -11499,42 +11499,68 @@ var common_request_wsClass = /*#__PURE__*/function () {
11499
11499
  Object.assign(this.config, {
11500
11500
  checkData: JSON.stringify(GetSendModel('keeplive', this.config))
11501
11501
  });
11502
- this.socket = common_request_useRequest('websocket')(config);
11503
- initWsBaseTheme(this.socket, {
11504
- onOpen: function onOpen(e) {
11505
- // 登录
11506
- console.log('====onOpen=====');
11507
- console.log(_this);
11508
-
11509
- _this.send('Login');
11510
-
11511
- _onOpen && _onOpen(e);
11512
- },
11513
- onClose: function onClose(e) {
11514
- _onClose && _onClose(e);
11515
- },
11516
- onMessage: function onMessage(e) {
11517
- var data = e.data || e;
11518
-
11519
- if (data.indexOf('Back_Login(') === 0) {
11520
- // 设置坐席
11521
- _this.config.AgentGroupName && _this.send("SetGroupRole", _this.config.AgentGroupName); // 初始化操作
11522
-
11523
- initAction && initAction(); // return
11524
- }
11525
-
11526
- _onMessage && _onMessage(e);
11527
- },
11528
- onError: function onError(e) {
11529
- _onError && _onError(e);
11530
- },
11531
- onReconnect: function onReconnect(e) {
11532
- _this.scoket = e;
11533
- }
11502
+ this.socket = common_request_useRequest('websocket')(config, this);
11503
+ this.initSocket({
11504
+ onOpen: onOpen,
11505
+ onClose: onClose,
11506
+ onMessage: onMessage,
11507
+ onError: onError,
11508
+ initAction: initAction
11534
11509
  });
11535
11510
  }
11536
11511
 
11537
11512
  Object(createClass["a" /* default */])(wsClass, [{
11513
+ key: "initSocket",
11514
+ value: function initSocket(_ref3) {
11515
+ var _this = this;
11516
+
11517
+ var _onOpen = _ref3.onOpen,
11518
+ _onClose = _ref3.onClose,
11519
+ _onMessage = _ref3.onMessage,
11520
+ _onError = _ref3.onError,
11521
+ initAction = _ref3.initAction;
11522
+ initWsBaseTheme(this.socket, {
11523
+ onOpen: function onOpen(e) {
11524
+ // 登录
11525
+ console.log('====onOpen=====');
11526
+ console.log(_this);
11527
+
11528
+ _this.send('Login');
11529
+
11530
+ _onOpen && _onOpen(e);
11531
+ },
11532
+ onClose: function onClose(e) {
11533
+ _onClose && _onClose(e);
11534
+ },
11535
+ onMessage: function onMessage(e) {
11536
+ var data = e.data || e;
11537
+
11538
+ if (data.indexOf('Back_Login(') === 0) {
11539
+ // 设置坐席
11540
+ _this.config.AgentGroupName && _this.send("SetGroupRole", _this.config.AgentGroupName); // 初始化操作
11541
+
11542
+ initAction && initAction(); // return
11543
+ }
11544
+
11545
+ _onMessage && _onMessage(e);
11546
+ },
11547
+ onError: function onError(e) {
11548
+ _onError && _onError(e);
11549
+ },
11550
+ onReconnect: function onReconnect(e) {
11551
+ _this.scoket = e;
11552
+
11553
+ _this.initSocket({
11554
+ onOpen: _onOpen,
11555
+ onClose: _onClose,
11556
+ onMessage: _onMessage,
11557
+ onError: _onError,
11558
+ initAction: initAction
11559
+ });
11560
+ }
11561
+ });
11562
+ }
11563
+ }, {
11538
11564
  key: "send",
11539
11565
  value: function send(action, params) {
11540
11566
  var _this$socket;
@@ -11577,6 +11603,7 @@ var common_request_wsClass = /*#__PURE__*/function () {
11577
11603
 
11578
11604
  _classPrivateFieldSet(this, _player, null);
11579
11605
 
11606
+ this.socketTimer && clearTimeout(this.socketTimer);
11580
11607
  (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closeSocket(1000, '通知关闭websocket连接');
11581
11608
  this.socket = null;
11582
11609
 
@@ -11591,12 +11618,12 @@ var common_request_wsClass = /*#__PURE__*/function () {
11591
11618
  return wsClass;
11592
11619
  }();
11593
11620
 
11594
- var useKUcservice = function useKUcservice(options, _ref3) {
11595
- var onOpen = _ref3.onOpen,
11596
- onClose = _ref3.onClose,
11597
- onMessage = _ref3.onMessage,
11598
- onError = _ref3.onError,
11599
- initAction = _ref3.initAction;
11621
+ var useKUcservice = function useKUcservice(options, _ref4) {
11622
+ var onOpen = _ref4.onOpen,
11623
+ onClose = _ref4.onClose,
11624
+ onMessage = _ref4.onMessage,
11625
+ onError = _ref4.onError,
11626
+ initAction = _ref4.initAction;
11600
11627
  if (!window.WebSocket) return console.error('您的浏览器不支持WebSocket, 请更换浏览器!');
11601
11628
  return new common_request_wsClass(options, {
11602
11629
  onOpen: onOpen,
Binary file