ztxkutils 2.10.31 → 2.10.33
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/stompClient.d.ts +1 -0
- package/dist/stompClient.js +19 -28
- package/package.json +1 -1
package/dist/stompClient.d.ts
CHANGED
package/dist/stompClient.js
CHANGED
@@ -13,6 +13,7 @@ var StompClient = /** @class */ (function () {
|
|
13
13
|
this.successCallbacks = {}; // 连接成功执行的回调存储对象
|
14
14
|
this.errorCallbacks = {}; // 连接失败执行的回调存储对象
|
15
15
|
this.reconnectionNum = 0; // 重连次数
|
16
|
+
this.userClose = false; // 是否用户主动关闭
|
16
17
|
this.isInit = false;
|
17
18
|
this.connectWsConfig = connectWsConfig;
|
18
19
|
}
|
@@ -129,6 +130,23 @@ var StompClient = /** @class */ (function () {
|
|
129
130
|
function (err) {
|
130
131
|
console.log("---------\u8FDE\u63A5\u5931\u8D25 system=" + _this.connectWsConfig.systemType + " time=" + Date.now() + "--------");
|
131
132
|
console.log(err);
|
133
|
+
if (_this.userClose) {
|
134
|
+
_this.userClose = false; // 重新初始化 重新计算
|
135
|
+
if (_this.clearIsClient) {
|
136
|
+
clearTimeout(_this.clearIsClient);
|
137
|
+
_this.clearIsClient = null;
|
138
|
+
}
|
139
|
+
if (_this.clearIsClientNo) {
|
140
|
+
clearTimeout(_this.clearIsClientNo);
|
141
|
+
_this.clearIsClientNo = null;
|
142
|
+
}
|
143
|
+
if (_this.clearIsClientYes) {
|
144
|
+
clearTimeout(_this.clearIsClientYes);
|
145
|
+
_this.clearIsClientYes = null;
|
146
|
+
}
|
147
|
+
console.log('用户主动关闭');
|
148
|
+
return;
|
149
|
+
}
|
132
150
|
_this.isClient = true;
|
133
151
|
if (_this.clearIsClient) {
|
134
152
|
clearTimeout(_this.clearIsClient);
|
@@ -247,43 +265,16 @@ var StompClient = /** @class */ (function () {
|
|
247
265
|
StompClient.prototype.disconnect = function (callback) {
|
248
266
|
var _this = this;
|
249
267
|
this.isInit = false;
|
268
|
+
this.userClose = true;
|
250
269
|
return new Promise(function (resolve, reject) {
|
251
270
|
try {
|
252
271
|
_this.client.disconnect(function () {
|
253
272
|
_this.client = null;
|
254
|
-
setTimeout(function () {
|
255
|
-
if (_this.clearIsClient) {
|
256
|
-
clearTimeout(_this.clearIsClient);
|
257
|
-
_this.clearIsClient = null;
|
258
|
-
}
|
259
|
-
if (_this.clearIsClientNo) {
|
260
|
-
clearTimeout(_this.clearIsClientNo);
|
261
|
-
_this.clearIsClientNo = null;
|
262
|
-
}
|
263
|
-
if (_this.clearIsClientYes) {
|
264
|
-
clearTimeout(_this.clearIsClientYes);
|
265
|
-
_this.clearIsClientYes = null;
|
266
|
-
}
|
267
|
-
}, 300);
|
268
273
|
callback && callback();
|
269
274
|
resolve(null);
|
270
275
|
});
|
271
276
|
}
|
272
277
|
catch (err) {
|
273
|
-
setTimeout(function () {
|
274
|
-
if (_this.clearIsClient) {
|
275
|
-
clearTimeout(_this.clearIsClient);
|
276
|
-
_this.clearIsClient = null;
|
277
|
-
}
|
278
|
-
if (_this.clearIsClientNo) {
|
279
|
-
clearTimeout(_this.clearIsClientNo);
|
280
|
-
_this.clearIsClientNo = null;
|
281
|
-
}
|
282
|
-
if (_this.clearIsClientYes) {
|
283
|
-
clearTimeout(_this.clearIsClientYes);
|
284
|
-
_this.clearIsClientYes = null;
|
285
|
-
}
|
286
|
-
}, 300);
|
287
278
|
callback && callback();
|
288
279
|
resolve(null);
|
289
280
|
}
|