ztxkutils 2.7.2 → 2.7.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.
@@ -15,6 +15,8 @@ declare class StompClient {
15
15
  static getInstance: (connectWsConfig?: IConnectWsConfig) => StompClient;
16
16
  connectWsConfig: IConnectWsConfig;
17
17
  client: any;
18
+ isClient: any;
19
+ clearIsClient: any;
18
20
  subscriptions: any;
19
21
  subscriptionsFn: any;
20
22
  successCallbacks: any;
@@ -4,6 +4,8 @@ import { g as getToken } from './authority-fad2028d.js';
4
4
 
5
5
  var StompClient = /** @class */ (function () {
6
6
  function StompClient(connectWsConfig) {
7
+ this.isClient = false; // 是否连接上了
8
+ this.clearIsClient = null;
7
9
  this.subscriptions = {}; // 连接通道的返回值存储对象
8
10
  this.subscriptionsFn = {}; // 连接通道的函数存储对象
9
11
  this.successCallbacks = {}; // 连接成功执行的回调存储对象
@@ -22,6 +24,23 @@ var StompClient = /** @class */ (function () {
22
24
  var socket = new SockJS(this.connectWsConfig.baseUrl + "/api/zmdms-csc-ztim/ws?token=" + token + "&system=" + this.connectWsConfig.systemType + "&clientType=" + this.connectWsConfig.clientType);
23
25
  // 获取 STOMP 子协议的客户端对象
24
26
  this.client = Stomp.over(socket);
27
+ this.clearIsClient = setTimeout(function () {
28
+ if (!_this.isClient) {
29
+ console.log("\u8FDE\u63A5\u5DF2\u53D1\u8D77\uFF0C\u4F46\u662F10\u79D2\u540E\u672A\u6210\u529F\u5EFA\u7ACB\u8FDE\u63A5\uFF0C\u624B\u52A8\u65AD\u5F00\u91CD\u8FDE!");
30
+ _this.client.disconnect(function () {
31
+ _this.client = null;
32
+ _this.reconnectionNum++;
33
+ // const timeInterval =
34
+ // Math.ceil(this.reconnectionNum / 5) *
35
+ // (this.connectWsConfig.reconnectionTime ?? 3000);
36
+ var timeInterval = 3000;
37
+ console.log("\u7B2C" + _this.reconnectionNum + "\u6B21\u91CD\u8FDE\uFF01");
38
+ setTimeout(function () {
39
+ _this.init();
40
+ }, timeInterval);
41
+ });
42
+ }
43
+ }, 10000);
25
44
  // 拦截输出的一大堆垃圾信息
26
45
  this.client.debug = function (str) {
27
46
  if (_this.connectWsConfig.debug) {
@@ -36,6 +55,10 @@ var StompClient = /** @class */ (function () {
36
55
  this.client.connect({},
37
56
  // 连接成功回调
38
57
  function () {
58
+ _this.isClient = true;
59
+ if (_this.clearIsClient) {
60
+ clearTimeout(_this.clearIsClient);
61
+ }
39
62
  _this.reconnectionNum = 0;
40
63
  console.log('---------连接成功--------');
41
64
  // 连接成功后,将当前已注册的,未执行的 连接通道 连接
@@ -72,6 +95,10 @@ var StompClient = /** @class */ (function () {
72
95
  function (err) {
73
96
  console.log('---------连接失败--------');
74
97
  console.log(err);
98
+ _this.isClient = true;
99
+ if (_this.clearIsClient) {
100
+ clearTimeout(_this.clearIsClient);
101
+ }
75
102
  // this.errorCallback(err);
76
103
  // 连接失败后,将当前已注册的 连接通道 全部置为未执行状态
77
104
  var subscriptionsFnKeys = Object.keys(_this.subscriptionsFn);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",