kucservice 1.5.1 → 1.5.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.
@@ -2182,6 +2182,8 @@ var websocket_Socket = /*#__PURE__*/function (_WebSocket) {
2182
2182
 
2183
2183
  Object(defineProperty["a" /* default */])(_assertThisInitialized(_this), "firstConnect", false);
2184
2184
 
2185
+ Object(defineProperty["a" /* default */])(_assertThisInitialized(_this), "isManualClose", false);
2186
+
2185
2187
  _this.self = _self;
2186
2188
  _this._currentOptions = options;
2187
2189
  _this._dep = dep;
@@ -2216,7 +2218,7 @@ var websocket_Socket = /*#__PURE__*/function (_WebSocket) {
2216
2218
  this._dep.notify('close', e); // 如果WebSocket是非正常关闭 则进行重连
2217
2219
 
2218
2220
 
2219
- if (e.code !== CLOSE_ABNORMAL) {
2221
+ if (e.code !== CLOSE_ABNORMAL && !this.isManualClose) {
2220
2222
  var _this$self;
2221
2223
 
2222
2224
  // if (this._reconnectCount < this.heartCheckCount) {
@@ -2233,7 +2235,12 @@ var websocket_Socket = /*#__PURE__*/function (_WebSocket) {
2233
2235
  this.self.socketTimer = setTimeout(function () {
2234
2236
  var _socket = new Socket(optionsClone, _this2._dep, _this2._reconnectCount, _this2.self);
2235
2237
 
2236
- _this2.closeSocket();
2238
+ _this2.clearHeartCheck();
2239
+
2240
+ _this2.onopen = null;
2241
+ _this2.onclose = null;
2242
+ _this2.onerror = null;
2243
+ _this2.onmessage = null;
2237
2244
 
2238
2245
  _this2._dep.notify('reconnect', _socket);
2239
2246
  }, TIMEOUT);
@@ -2241,6 +2248,15 @@ var websocket_Socket = /*#__PURE__*/function (_WebSocket) {
2241
2248
  // return console.error('WebSocket重连失败, 请联系技术客服!')
2242
2249
  // }
2243
2250
 
2251
+ } else {
2252
+ this.isManualClose = false;
2253
+ this.clearHeartCheck();
2254
+ this.onopen = null;
2255
+ this.onclose = null;
2256
+ this.onerror = null;
2257
+ this.onmessage = null;
2258
+
2259
+ this._dep.notify('close', e, true);
2244
2260
  }
2245
2261
  };
2246
2262
 
@@ -2302,13 +2318,16 @@ var websocket_Socket = /*#__PURE__*/function (_WebSocket) {
2302
2318
  }, {
2303
2319
  key: "closeSocket",
2304
2320
  value: function closeSocket(code, reason) {
2321
+ this.isManualClose = true;
2305
2322
  this.clearHeartCheck();
2306
- console.log('=====close code===', code, reason);
2307
- this.onopen = null;
2308
- this.onclose = null;
2309
- this.onerror = null;
2310
- this.onmessage = null;
2311
- this.close(code || 1000, reason);
2323
+ console.log('=====close code===', code, reason); // this.onopen = null
2324
+ // this.onclose = null
2325
+ // this.onerror = null
2326
+ // this.onmessage = null
2327
+
2328
+ if (this && this.readyState === this.OPEN) {
2329
+ this.close(code || 1000, reason);
2330
+ }
2312
2331
  } // 开始心跳检测
2313
2332
 
2314
2333
  }, {
@@ -11404,9 +11423,10 @@ var initWsBaseTheme = function initWsBaseTheme(socket, _ref) {
11404
11423
  console.log('WebSocket连接成功!');
11405
11424
  onOpen && onOpen();
11406
11425
  });
11407
- socket.subscribe('close', function (reason) {
11426
+ socket.subscribe('close', function (reason, isManualClose) {
11408
11427
  console.log('WebSocket连接关闭!', reason);
11409
11428
  onClose && onClose(reason);
11429
+ isManualClose && (socket = null);
11410
11430
  });
11411
11431
  socket.subscribe('message', function (result) {
11412
11432
  onMessage && onMessage(result);
@@ -11611,8 +11631,7 @@ var common_request_wsClass = /*#__PURE__*/function () {
11611
11631
  _classPrivateFieldSet(this, _player, null);
11612
11632
 
11613
11633
  this.socketTimer && clearTimeout(this.socketTimer);
11614
- (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closeSocket(1000, '通知关闭websocket连接');
11615
- this.socket = null;
11634
+ (_this$socket2 = this.socket) === null || _this$socket2 === void 0 ? void 0 : _this$socket2.closeSocket(1000, '通知关闭websocket连接'); // this.socket = null
11616
11635
 
11617
11636
  if (_classPrivateFieldGet(this, _phoneClientObj)) {
11618
11637
  _classPrivateFieldGet(this, _phoneClientObj).onclose();
Binary file