@pisell/core 0.0.2
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/README.md +1 -0
- package/es/app/app.d.ts +101 -0
- package/es/app/app.js +177 -0
- package/es/app/const.d.ts +4 -0
- package/es/app/const.js +6 -0
- package/es/app/index.d.ts +14 -0
- package/es/app/index.js +52 -0
- package/es/applicationManager/application.d.ts +197 -0
- package/es/applicationManager/application.js +469 -0
- package/es/applicationManager/index.d.ts +19 -0
- package/es/applicationManager/index.js +206 -0
- package/es/aws/index.d.ts +16 -0
- package/es/aws/index.js +76 -0
- package/es/cmd/const.d.ts +11 -0
- package/es/cmd/const.js +13 -0
- package/es/cmd/index.d.ts +13 -0
- package/es/cmd/index.js +91 -0
- package/es/cmd/type.d.ts +5 -0
- package/es/cmd/type.js +1 -0
- package/es/communicationManager/index.d.ts +59 -0
- package/es/communicationManager/index.js +174 -0
- package/es/config.d.ts +3 -0
- package/es/config.js +14 -0
- package/es/cookie/index.d.ts +13 -0
- package/es/cookie/index.js +47 -0
- package/es/css/global.less +73 -0
- package/es/css/index.less +31 -0
- package/es/css/variables.css +84 -0
- package/es/data/index.d.ts +8 -0
- package/es/data/index.js +16 -0
- package/es/history/config.d.ts +24 -0
- package/es/history/config.js +43 -0
- package/es/history/index.d.ts +26 -0
- package/es/history/index.js +80 -0
- package/es/history/type.d.ts +2 -0
- package/es/history/type.js +1 -0
- package/es/hooks/index.d.ts +12 -0
- package/es/hooks/index.js +13 -0
- package/es/hooks/useDelayedValue/index.d.ts +2 -0
- package/es/hooks/useDelayedValue/index.js +26 -0
- package/es/hooks/useDispatch/index.d.ts +2 -0
- package/es/hooks/useDispatch/index.js +2 -0
- package/es/hooks/useLowCode/index.d.ts +13 -0
- package/es/hooks/useLowCode/index.js +74 -0
- package/es/hooks/useStore/index.d.ts +6 -0
- package/es/hooks/useStore/index.js +11 -0
- package/es/index.d.ts +8 -0
- package/es/index.js +10 -0
- package/es/indexDB/index.d.ts +296 -0
- package/es/indexDB/index.js +1619 -0
- package/es/locales/en.d.ts +3 -0
- package/es/locales/en.js +5 -0
- package/es/locales/index.d.ts +39 -0
- package/es/locales/index.js +199 -0
- package/es/locales/original.d.ts +3 -0
- package/es/locales/original.js +7 -0
- package/es/locales/type.d.ts +19 -0
- package/es/locales/type.js +1 -0
- package/es/locales/zh-CN.d.ts +3 -0
- package/es/locales/zh-CN.js +5 -0
- package/es/locales/zh-HK.d.ts +3 -0
- package/es/locales/zh-HK.js +5 -0
- package/es/logger/feishu.d.ts +11 -0
- package/es/logger/feishu.js +50 -0
- package/es/logger/index.d.ts +135 -0
- package/es/logger/index.js +870 -0
- package/es/menuManager/hooks.d.ts +17 -0
- package/es/menuManager/hooks.js +136 -0
- package/es/menuManager/index.d.ts +28 -0
- package/es/menuManager/index.js +165 -0
- package/es/models/global.d.ts +32 -0
- package/es/models/global.js +66 -0
- package/es/models/index.d.ts +45 -0
- package/es/models/index.js +65 -0
- package/es/models/type.d.ts +2 -0
- package/es/models/type.js +1 -0
- package/es/plugin/index.d.ts +0 -0
- package/es/plugin/index.js +0 -0
- package/es/pubsub/example.d.ts +5 -0
- package/es/pubsub/example.js +92 -0
- package/es/pubsub/index.d.ts +73 -0
- package/es/pubsub/index.js +166 -0
- package/es/render/index.d.ts +0 -0
- package/es/render/index.js +0 -0
- package/es/request/cache.d.ts +46 -0
- package/es/request/cache.js +372 -0
- package/es/request/cancelToken.d.ts +38 -0
- package/es/request/cancelToken.js +59 -0
- package/es/request/config.d.ts +3 -0
- package/es/request/config.js +63 -0
- package/es/request/constants.d.ts +2 -0
- package/es/request/constants.js +6 -0
- package/es/request/index.d.ts +24 -0
- package/es/request/index.js +267 -0
- package/es/request/pisell2Request.d.ts +6 -0
- package/es/request/pisell2Request.js +62 -0
- package/es/request/type.d.ts +57 -0
- package/es/request/type.js +10 -0
- package/es/request/utils.d.ts +46 -0
- package/es/request/utils.js +147 -0
- package/es/routes/config.d.ts +7 -0
- package/es/routes/config.js +17 -0
- package/es/routes/index.d.ts +28 -0
- package/es/routes/index.js +151 -0
- package/es/socket/components/SocketMonitorPage.d.ts +6 -0
- package/es/socket/components/SocketMonitorPage.js +485 -0
- package/es/socket/components/index.d.ts +2 -0
- package/es/socket/components/index.js +2 -0
- package/es/socket/constants.d.ts +33 -0
- package/es/socket/constants.js +39 -0
- package/es/socket/events.d.ts +31 -0
- package/es/socket/events.js +19 -0
- package/es/socket/heartbeat.d.ts +66 -0
- package/es/socket/heartbeat.js +184 -0
- package/es/socket/index.d.ts +61 -0
- package/es/socket/index.js +246 -0
- package/es/socket/monitor.d.ts +169 -0
- package/es/socket/monitor.js +448 -0
- package/es/socket/reconnect.d.ts +61 -0
- package/es/socket/reconnect.js +199 -0
- package/es/socket/socket.d.ts +130 -0
- package/es/socket/socket.js +613 -0
- package/es/socket/types.d.ts +85 -0
- package/es/socket/types.js +35 -0
- package/es/storage/index.d.ts +17 -0
- package/es/storage/index.js +46 -0
- package/es/tasks/index.d.ts +127 -0
- package/es/tasks/index.js +1119 -0
- package/es/tasks/scheduledTasksExample.d.ts +61 -0
- package/es/tasks/scheduledTasksExample.js +351 -0
- package/es/tasks/type.d.ts +100 -0
- package/es/tasks/type.js +1 -0
- package/es/tasks/useTasks.d.ts +5 -0
- package/es/tasks/useTasks.js +25 -0
- package/es/type.d.ts +2 -0
- package/es/type.js +1 -0
- package/es/utils/adaptiveThrottle/index.d.ts +36 -0
- package/es/utils/adaptiveThrottle/index.js +136 -0
- package/es/variables/VariablesProvider.d.ts +7 -0
- package/es/variables/VariablesProvider.js +12 -0
- package/es/variables/config.d.ts +3 -0
- package/es/variables/config.js +16 -0
- package/es/variables/index.d.ts +6 -0
- package/es/variables/index.js +5 -0
- package/es/variables/type.d.ts +2 -0
- package/es/variables/type.js +1 -0
- package/es/website/index.d.ts +6 -0
- package/es/website/index.js +65 -0
- package/lib/app/app.d.ts +101 -0
- package/lib/app/app.js +171 -0
- package/lib/app/const.d.ts +4 -0
- package/lib/app/const.js +33 -0
- package/lib/app/index.d.ts +14 -0
- package/lib/app/index.js +76 -0
- package/lib/applicationManager/application.d.ts +197 -0
- package/lib/applicationManager/application.js +280 -0
- package/lib/applicationManager/index.d.ts +19 -0
- package/lib/applicationManager/index.js +88 -0
- package/lib/aws/index.d.ts +16 -0
- package/lib/aws/index.js +67 -0
- package/lib/cmd/const.d.ts +11 -0
- package/lib/cmd/const.js +39 -0
- package/lib/cmd/index.d.ts +13 -0
- package/lib/cmd/index.js +96 -0
- package/lib/cmd/type.d.ts +5 -0
- package/lib/cmd/type.js +17 -0
- package/lib/communicationManager/index.d.ts +59 -0
- package/lib/communicationManager/index.js +102 -0
- package/lib/config.d.ts +3 -0
- package/lib/config.js +36 -0
- package/lib/cookie/index.d.ts +13 -0
- package/lib/cookie/index.js +62 -0
- package/lib/css/global.less +73 -0
- package/lib/css/index.less +31 -0
- package/lib/css/variables.css +84 -0
- package/lib/data/index.d.ts +8 -0
- package/lib/data/index.js +38 -0
- package/lib/history/config.d.ts +24 -0
- package/lib/history/config.js +41 -0
- package/lib/history/index.d.ts +26 -0
- package/lib/history/index.js +99 -0
- package/lib/history/type.d.ts +2 -0
- package/lib/history/type.js +17 -0
- package/lib/hooks/index.d.ts +12 -0
- package/lib/hooks/index.js +44 -0
- package/lib/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/hooks/useDelayedValue/index.js +36 -0
- package/lib/hooks/useDispatch/index.d.ts +2 -0
- package/lib/hooks/useDispatch/index.js +26 -0
- package/lib/hooks/useLowCode/index.d.ts +13 -0
- package/lib/hooks/useLowCode/index.js +75 -0
- package/lib/hooks/useStore/index.d.ts +6 -0
- package/lib/hooks/useStore/index.js +33 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +58 -0
- package/lib/indexDB/index.d.ts +296 -0
- package/lib/indexDB/index.js +767 -0
- package/lib/locales/en.d.ts +3 -0
- package/lib/locales/en.js +29 -0
- package/lib/locales/index.d.ts +39 -0
- package/lib/locales/index.js +159 -0
- package/lib/locales/original.d.ts +3 -0
- package/lib/locales/original.js +31 -0
- package/lib/locales/type.d.ts +19 -0
- package/lib/locales/type.js +17 -0
- package/lib/locales/zh-CN.d.ts +3 -0
- package/lib/locales/zh-CN.js +29 -0
- package/lib/locales/zh-HK.d.ts +3 -0
- package/lib/locales/zh-HK.js +29 -0
- package/lib/logger/feishu.d.ts +11 -0
- package/lib/logger/feishu.js +52 -0
- package/lib/logger/index.d.ts +135 -0
- package/lib/logger/index.js +476 -0
- package/lib/menuManager/hooks.d.ts +17 -0
- package/lib/menuManager/hooks.js +135 -0
- package/lib/menuManager/index.d.ts +28 -0
- package/lib/menuManager/index.js +125 -0
- package/lib/models/global.d.ts +32 -0
- package/lib/models/global.js +62 -0
- package/lib/models/index.d.ts +45 -0
- package/lib/models/index.js +69 -0
- package/lib/models/type.d.ts +2 -0
- package/lib/models/type.js +17 -0
- package/lib/plugin/index.d.ts +0 -0
- package/lib/plugin/index.js +0 -0
- package/lib/pubsub/example.d.ts +5 -0
- package/lib/pubsub/example.js +61 -0
- package/lib/pubsub/index.d.ts +73 -0
- package/lib/pubsub/index.js +141 -0
- package/lib/render/index.d.ts +0 -0
- package/lib/render/index.js +0 -0
- package/lib/request/cache.d.ts +46 -0
- package/lib/request/cache.js +195 -0
- package/lib/request/cancelToken.d.ts +38 -0
- package/lib/request/cancelToken.js +59 -0
- package/lib/request/config.d.ts +3 -0
- package/lib/request/config.js +69 -0
- package/lib/request/constants.d.ts +2 -0
- package/lib/request/constants.js +34 -0
- package/lib/request/index.d.ts +24 -0
- package/lib/request/index.js +210 -0
- package/lib/request/pisell2Request.d.ts +6 -0
- package/lib/request/pisell2Request.js +75 -0
- package/lib/request/type.d.ts +57 -0
- package/lib/request/type.js +36 -0
- package/lib/request/utils.d.ts +46 -0
- package/lib/request/utils.js +113 -0
- package/lib/routes/config.d.ts +7 -0
- package/lib/routes/config.js +50 -0
- package/lib/routes/index.d.ts +28 -0
- package/lib/routes/index.js +121 -0
- package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/socket/components/SocketMonitorPage.js +340 -0
- package/lib/socket/components/index.d.ts +2 -0
- package/lib/socket/components/index.js +39 -0
- package/lib/socket/constants.d.ts +33 -0
- package/lib/socket/constants.js +62 -0
- package/lib/socket/events.d.ts +31 -0
- package/lib/socket/events.js +44 -0
- package/lib/socket/heartbeat.d.ts +66 -0
- package/lib/socket/heartbeat.js +157 -0
- package/lib/socket/index.d.ts +61 -0
- package/lib/socket/index.js +198 -0
- package/lib/socket/monitor.d.ts +169 -0
- package/lib/socket/monitor.js +350 -0
- package/lib/socket/reconnect.d.ts +61 -0
- package/lib/socket/reconnect.js +157 -0
- package/lib/socket/socket.d.ts +130 -0
- package/lib/socket/socket.js +426 -0
- package/lib/socket/types.d.ts +85 -0
- package/lib/socket/types.js +36 -0
- package/lib/storage/index.d.ts +17 -0
- package/lib/storage/index.js +64 -0
- package/lib/tasks/index.d.ts +127 -0
- package/lib/tasks/index.js +710 -0
- package/lib/tasks/scheduledTasksExample.d.ts +61 -0
- package/lib/tasks/scheduledTasksExample.js +267 -0
- package/lib/tasks/type.d.ts +100 -0
- package/lib/tasks/type.js +17 -0
- package/lib/tasks/useTasks.d.ts +5 -0
- package/lib/tasks/useTasks.js +37 -0
- package/lib/type.d.ts +2 -0
- package/lib/type.js +17 -0
- package/lib/utils/adaptiveThrottle/index.d.ts +36 -0
- package/lib/utils/adaptiveThrottle/index.js +121 -0
- package/lib/variables/VariablesProvider.d.ts +7 -0
- package/lib/variables/VariablesProvider.js +51 -0
- package/lib/variables/config.d.ts +3 -0
- package/lib/variables/config.js +38 -0
- package/lib/variables/index.d.ts +6 -0
- package/lib/variables/index.js +29 -0
- package/lib/variables/type.d.ts +2 -0
- package/lib/variables/type.js +17 -0
- package/lib/website/index.d.ts +6 -0
- package/lib/website/index.js +75 -0
- package/package.json +49 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/socket/monitor.ts
|
|
20
|
+
var monitor_exports = {};
|
|
21
|
+
__export(monitor_exports, {
|
|
22
|
+
SocketMonitor: () => SocketMonitor
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(monitor_exports);
|
|
25
|
+
var import_events = require("./events");
|
|
26
|
+
var import_types = require("./types");
|
|
27
|
+
var SocketMonitor = class {
|
|
28
|
+
socket;
|
|
29
|
+
options;
|
|
30
|
+
isMonitoring = false;
|
|
31
|
+
// 历史记录存储
|
|
32
|
+
messageHistory = [];
|
|
33
|
+
statusHistory = [];
|
|
34
|
+
// 统计数据
|
|
35
|
+
stats = {
|
|
36
|
+
totalSent: 0,
|
|
37
|
+
totalReceived: 0,
|
|
38
|
+
bytesSent: 0,
|
|
39
|
+
bytesReceived: 0,
|
|
40
|
+
connectionCount: 0,
|
|
41
|
+
reconnectionCount: 0,
|
|
42
|
+
errorCount: 0,
|
|
43
|
+
heartbeatCount: 0,
|
|
44
|
+
heartbeatTimeoutCount: 0,
|
|
45
|
+
firstConnectTime: null,
|
|
46
|
+
lastConnectTime: null,
|
|
47
|
+
currentConnectionDuration: null,
|
|
48
|
+
averageMessageSize: 0
|
|
49
|
+
};
|
|
50
|
+
// 用于计算连接持续时间
|
|
51
|
+
connectStartTime = null;
|
|
52
|
+
// 事件句柄映射
|
|
53
|
+
eventHandlers = /* @__PURE__ */ new Map();
|
|
54
|
+
/**
|
|
55
|
+
* 创建Socket监控器
|
|
56
|
+
* @param socket 要监控的Socket实例
|
|
57
|
+
* @param options 监控配置选项
|
|
58
|
+
*/
|
|
59
|
+
constructor(socket, options = {}) {
|
|
60
|
+
this.socket = socket;
|
|
61
|
+
this.options = {
|
|
62
|
+
maxHistoryItems: 100,
|
|
63
|
+
maxStatusItems: 50,
|
|
64
|
+
recordMessageContent: true,
|
|
65
|
+
autoStart: true,
|
|
66
|
+
excludeEvents: ["ping", "pong", "heartbeat"],
|
|
67
|
+
...options
|
|
68
|
+
};
|
|
69
|
+
if (this.options.autoStart) {
|
|
70
|
+
this.start();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 开始监控
|
|
75
|
+
*/
|
|
76
|
+
start() {
|
|
77
|
+
if (this.isMonitoring) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.isMonitoring = true;
|
|
81
|
+
this.setupEventListeners();
|
|
82
|
+
this.recordStatusChange(import_types.SocketStatus.CLOSED, this.socket.getStatus());
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 停止监控
|
|
86
|
+
*/
|
|
87
|
+
stop() {
|
|
88
|
+
if (!this.isMonitoring) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.isMonitoring = false;
|
|
92
|
+
this.removeEventListeners();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 检查监控器是否处于活跃状态
|
|
96
|
+
*/
|
|
97
|
+
isActive() {
|
|
98
|
+
return this.isMonitoring;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 清除历史记录
|
|
102
|
+
*/
|
|
103
|
+
clearHistory() {
|
|
104
|
+
this.messageHistory = [];
|
|
105
|
+
this.statusHistory = [];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 重置统计数据
|
|
109
|
+
*/
|
|
110
|
+
resetStats() {
|
|
111
|
+
this.stats = {
|
|
112
|
+
totalSent: 0,
|
|
113
|
+
totalReceived: 0,
|
|
114
|
+
bytesSent: 0,
|
|
115
|
+
bytesReceived: 0,
|
|
116
|
+
connectionCount: 0,
|
|
117
|
+
reconnectionCount: 0,
|
|
118
|
+
errorCount: 0,
|
|
119
|
+
heartbeatCount: 0,
|
|
120
|
+
heartbeatTimeoutCount: 0,
|
|
121
|
+
firstConnectTime: null,
|
|
122
|
+
lastConnectTime: null,
|
|
123
|
+
currentConnectionDuration: null,
|
|
124
|
+
averageMessageSize: 0
|
|
125
|
+
};
|
|
126
|
+
this.connectStartTime = null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 获取消息历史记录
|
|
130
|
+
* @param limit 返回的最大记录数
|
|
131
|
+
* @param direction 消息方向过滤
|
|
132
|
+
*/
|
|
133
|
+
getMessageHistory(limit, direction) {
|
|
134
|
+
let history = this.messageHistory;
|
|
135
|
+
if (direction) {
|
|
136
|
+
history = history.filter((item) => item.direction === direction);
|
|
137
|
+
}
|
|
138
|
+
if (limit && limit > 0) {
|
|
139
|
+
history = history.slice(-limit);
|
|
140
|
+
}
|
|
141
|
+
return history;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 获取状态变更历史
|
|
145
|
+
* @param limit 返回的最大记录数
|
|
146
|
+
*/
|
|
147
|
+
getStatusHistory(limit) {
|
|
148
|
+
let history = this.statusHistory;
|
|
149
|
+
if (limit && limit > 0) {
|
|
150
|
+
history = history.slice(-limit);
|
|
151
|
+
}
|
|
152
|
+
return history;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* 获取统计信息
|
|
156
|
+
*/
|
|
157
|
+
getStats() {
|
|
158
|
+
if (this.socket.isConnected() && this.connectStartTime) {
|
|
159
|
+
this.stats.currentConnectionDuration = Date.now() - this.connectStartTime;
|
|
160
|
+
}
|
|
161
|
+
return { ...this.stats };
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 设置监控事件监听
|
|
165
|
+
*/
|
|
166
|
+
setupEventListeners() {
|
|
167
|
+
const onSend = (message) => {
|
|
168
|
+
this.recordMessageSent(message);
|
|
169
|
+
};
|
|
170
|
+
this.eventHandlers.set(import_events.SocketEvents.SEND, onSend);
|
|
171
|
+
this.socket.on(import_events.SocketEvents.SEND, onSend);
|
|
172
|
+
const onMessage = (message) => {
|
|
173
|
+
this.recordMessageReceived(message);
|
|
174
|
+
};
|
|
175
|
+
this.eventHandlers.set(import_events.SocketEvents.MESSAGE, onMessage);
|
|
176
|
+
this.socket.on(import_events.SocketEvents.MESSAGE, onMessage);
|
|
177
|
+
const onConnect = () => {
|
|
178
|
+
const now = Date.now();
|
|
179
|
+
this.connectStartTime = now;
|
|
180
|
+
if (!this.stats.firstConnectTime) {
|
|
181
|
+
this.stats.firstConnectTime = now;
|
|
182
|
+
}
|
|
183
|
+
this.stats.lastConnectTime = now;
|
|
184
|
+
this.stats.connectionCount++;
|
|
185
|
+
this.recordStatusChange(
|
|
186
|
+
this.socket.getStatus() === import_types.SocketStatus.RECONNECTING ? import_types.SocketStatus.RECONNECTING : import_types.SocketStatus.CONNECTING,
|
|
187
|
+
import_types.SocketStatus.OPEN,
|
|
188
|
+
import_events.SocketEvents.CONNECT
|
|
189
|
+
);
|
|
190
|
+
};
|
|
191
|
+
this.eventHandlers.set(import_events.SocketEvents.CONNECT, onConnect);
|
|
192
|
+
this.socket.on(import_events.SocketEvents.CONNECT, onConnect);
|
|
193
|
+
const onDisconnect = () => {
|
|
194
|
+
this.connectStartTime = null;
|
|
195
|
+
this.stats.currentConnectionDuration = null;
|
|
196
|
+
this.recordStatusChange(
|
|
197
|
+
this.socket.getStatus() === import_types.SocketStatus.CLOSING ? import_types.SocketStatus.CLOSING : import_types.SocketStatus.OPEN,
|
|
198
|
+
import_types.SocketStatus.CLOSED,
|
|
199
|
+
import_events.SocketEvents.DISCONNECT
|
|
200
|
+
);
|
|
201
|
+
};
|
|
202
|
+
this.eventHandlers.set(import_events.SocketEvents.DISCONNECT, onDisconnect);
|
|
203
|
+
this.socket.on(import_events.SocketEvents.DISCONNECT, onDisconnect);
|
|
204
|
+
const onReconnect = () => {
|
|
205
|
+
this.stats.reconnectionCount++;
|
|
206
|
+
};
|
|
207
|
+
this.eventHandlers.set(import_events.SocketEvents.RECONNECT, onReconnect);
|
|
208
|
+
this.socket.on(import_events.SocketEvents.RECONNECT, onReconnect);
|
|
209
|
+
const onReconnectAttempt = () => {
|
|
210
|
+
this.recordStatusChange(
|
|
211
|
+
import_types.SocketStatus.CLOSED,
|
|
212
|
+
import_types.SocketStatus.RECONNECTING,
|
|
213
|
+
import_events.SocketEvents.RECONNECT_ATTEMPT
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
this.eventHandlers.set(import_events.SocketEvents.RECONNECT_ATTEMPT, onReconnectAttempt);
|
|
217
|
+
this.socket.on(import_events.SocketEvents.RECONNECT_ATTEMPT, onReconnectAttempt);
|
|
218
|
+
const onError = (error) => {
|
|
219
|
+
this.stats.errorCount++;
|
|
220
|
+
this.recordStatusChange(
|
|
221
|
+
this.socket.getStatus(),
|
|
222
|
+
this.socket.getStatus(),
|
|
223
|
+
import_events.SocketEvents.ERROR,
|
|
224
|
+
error
|
|
225
|
+
);
|
|
226
|
+
};
|
|
227
|
+
this.eventHandlers.set(import_events.SocketEvents.ERROR, onError);
|
|
228
|
+
this.socket.on(import_events.SocketEvents.ERROR, onError);
|
|
229
|
+
const onHeartbeat = () => {
|
|
230
|
+
this.stats.heartbeatCount++;
|
|
231
|
+
};
|
|
232
|
+
this.eventHandlers.set(import_events.SocketEvents.HEARTBEAT, onHeartbeat);
|
|
233
|
+
this.socket.on(import_events.SocketEvents.HEARTBEAT, onHeartbeat);
|
|
234
|
+
const onHeartbeatTimeout = () => {
|
|
235
|
+
this.stats.heartbeatTimeoutCount++;
|
|
236
|
+
};
|
|
237
|
+
this.eventHandlers.set(import_events.SocketEvents.HEARTBEAT_TIMEOUT, onHeartbeatTimeout);
|
|
238
|
+
this.socket.on(import_events.SocketEvents.HEARTBEAT_TIMEOUT, onHeartbeatTimeout);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* 移除监控事件监听
|
|
242
|
+
*/
|
|
243
|
+
removeEventListeners() {
|
|
244
|
+
for (const [event, handler] of this.eventHandlers.entries()) {
|
|
245
|
+
this.socket.off(event, handler);
|
|
246
|
+
}
|
|
247
|
+
this.eventHandlers.clear();
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* 记录已发送的消息
|
|
251
|
+
*/
|
|
252
|
+
recordMessageSent(message) {
|
|
253
|
+
var _a;
|
|
254
|
+
if ((_a = this.options.excludeEvents) == null ? void 0 : _a.includes(message.event)) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const messageStr = JSON.stringify(message);
|
|
258
|
+
const size = new Blob([messageStr]).size;
|
|
259
|
+
this.stats.totalSent++;
|
|
260
|
+
this.stats.bytesSent += size;
|
|
261
|
+
this.updateAverageMessageSize(size);
|
|
262
|
+
this.addToMessageHistory({
|
|
263
|
+
id: message.id || `out_${Date.now()}`,
|
|
264
|
+
timestamp: Date.now(),
|
|
265
|
+
direction: "out",
|
|
266
|
+
//@ts-ignore
|
|
267
|
+
message: this.options.recordMessageContent ? message : { event: message.event },
|
|
268
|
+
size
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* 记录已接收的消息
|
|
273
|
+
*/
|
|
274
|
+
recordMessageReceived(message) {
|
|
275
|
+
var _a;
|
|
276
|
+
if ((_a = this.options.excludeEvents) == null ? void 0 : _a.includes(message.event)) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const messageStr = JSON.stringify(message);
|
|
280
|
+
const size = new Blob([messageStr]).size;
|
|
281
|
+
this.stats.totalReceived++;
|
|
282
|
+
this.stats.bytesReceived += size;
|
|
283
|
+
this.updateAverageMessageSize(size);
|
|
284
|
+
this.addToMessageHistory({
|
|
285
|
+
id: message.id || `in_${Date.now()}`,
|
|
286
|
+
timestamp: Date.now(),
|
|
287
|
+
direction: "in",
|
|
288
|
+
//@ts-ignore
|
|
289
|
+
message: this.options.recordMessageContent ? message : { event: message.event },
|
|
290
|
+
size
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* 记录状态变化
|
|
295
|
+
*/
|
|
296
|
+
recordStatusChange(fromStatus, toStatus, event, info) {
|
|
297
|
+
if (fromStatus === toStatus && !event) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const statusItem = {
|
|
301
|
+
timestamp: Date.now(),
|
|
302
|
+
from: fromStatus,
|
|
303
|
+
to: toStatus,
|
|
304
|
+
event,
|
|
305
|
+
info
|
|
306
|
+
};
|
|
307
|
+
this.addToStatusHistory(statusItem);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* 添加消息到历史记录,并控制记录数量
|
|
311
|
+
*/
|
|
312
|
+
addToMessageHistory(item) {
|
|
313
|
+
this.messageHistory.push(item);
|
|
314
|
+
if (this.messageHistory.length > (this.options.maxHistoryItems || 100)) {
|
|
315
|
+
this.messageHistory.shift();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* 添加状态到历史记录,并控制记录数量
|
|
320
|
+
*/
|
|
321
|
+
addToStatusHistory(item) {
|
|
322
|
+
this.statusHistory.push(item);
|
|
323
|
+
if (this.statusHistory.length > (this.options.maxStatusItems || 50)) {
|
|
324
|
+
this.statusHistory.shift();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* 更新平均消息大小
|
|
329
|
+
*/
|
|
330
|
+
updateAverageMessageSize(newSize) {
|
|
331
|
+
const totalMessages = this.stats.totalSent + this.stats.totalReceived;
|
|
332
|
+
if (totalMessages <= 1) {
|
|
333
|
+
this.stats.averageMessageSize = newSize;
|
|
334
|
+
} else {
|
|
335
|
+
this.stats.averageMessageSize = (this.stats.averageMessageSize * (totalMessages - 1) + newSize) / totalMessages;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* 释放资源
|
|
340
|
+
*/
|
|
341
|
+
destroy() {
|
|
342
|
+
this.stop();
|
|
343
|
+
this.messageHistory = [];
|
|
344
|
+
this.statusHistory = [];
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
348
|
+
0 && (module.exports = {
|
|
349
|
+
SocketMonitor
|
|
350
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ReconnectOptions } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Socket重连管理器
|
|
4
|
+
* 处理断线重连逻辑
|
|
5
|
+
*/
|
|
6
|
+
export declare class ReconnectManager {
|
|
7
|
+
private options;
|
|
8
|
+
private attempts;
|
|
9
|
+
private timer;
|
|
10
|
+
private isReconnecting;
|
|
11
|
+
private reconnectCallback;
|
|
12
|
+
private onAttempt;
|
|
13
|
+
private onSuccess;
|
|
14
|
+
private onFail;
|
|
15
|
+
private onMaxAttemptsExceeded;
|
|
16
|
+
/**
|
|
17
|
+
* 创建重连管理器实例
|
|
18
|
+
* @param options 重连配置
|
|
19
|
+
* @param reconnectCallback 重连执行函数
|
|
20
|
+
* @param callbacks 回调函数集合
|
|
21
|
+
*/
|
|
22
|
+
constructor(options: ReconnectOptions, reconnectCallback: () => Promise<boolean>, callbacks?: {
|
|
23
|
+
onAttempt?: (attempt: number) => void;
|
|
24
|
+
onSuccess?: () => void;
|
|
25
|
+
onFail?: (error: Error) => void;
|
|
26
|
+
onMaxAttemptsExceeded?: () => void;
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* 启动重连过程
|
|
30
|
+
*/
|
|
31
|
+
startReconnect(): void;
|
|
32
|
+
/**
|
|
33
|
+
* 停止重连过程
|
|
34
|
+
*/
|
|
35
|
+
stopReconnect(): void;
|
|
36
|
+
/**
|
|
37
|
+
* 获取当前重连尝试次数
|
|
38
|
+
*/
|
|
39
|
+
getReconnectAttempts(): number;
|
|
40
|
+
/**
|
|
41
|
+
* 获取当前是否正在重连
|
|
42
|
+
*/
|
|
43
|
+
isActive(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* 重置重连状态
|
|
46
|
+
*/
|
|
47
|
+
reset(): void;
|
|
48
|
+
/**
|
|
49
|
+
* 安排下一次重连尝试
|
|
50
|
+
*/
|
|
51
|
+
private scheduleReconnect;
|
|
52
|
+
/**
|
|
53
|
+
* 执行重连操作
|
|
54
|
+
*/
|
|
55
|
+
private executeReconnect;
|
|
56
|
+
/**
|
|
57
|
+
* 计算重连延迟时间
|
|
58
|
+
* 支持指数退避算法,增加随机抖动
|
|
59
|
+
*/
|
|
60
|
+
private getReconnectDelay;
|
|
61
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/socket/reconnect.ts
|
|
20
|
+
var reconnect_exports = {};
|
|
21
|
+
__export(reconnect_exports, {
|
|
22
|
+
ReconnectManager: () => ReconnectManager
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(reconnect_exports);
|
|
25
|
+
var import_constants = require("./constants");
|
|
26
|
+
var ReconnectManager = class {
|
|
27
|
+
options;
|
|
28
|
+
attempts = 0;
|
|
29
|
+
timer = null;
|
|
30
|
+
isReconnecting = false;
|
|
31
|
+
// 重连回调函数
|
|
32
|
+
reconnectCallback;
|
|
33
|
+
onAttempt;
|
|
34
|
+
onSuccess;
|
|
35
|
+
onFail;
|
|
36
|
+
onMaxAttemptsExceeded;
|
|
37
|
+
/**
|
|
38
|
+
* 创建重连管理器实例
|
|
39
|
+
* @param options 重连配置
|
|
40
|
+
* @param reconnectCallback 重连执行函数
|
|
41
|
+
* @param callbacks 回调函数集合
|
|
42
|
+
*/
|
|
43
|
+
constructor(options, reconnectCallback, callbacks = {}) {
|
|
44
|
+
this.options = {
|
|
45
|
+
...options,
|
|
46
|
+
delay: Math.max(options.delay, import_constants.MIN_RECONNECTION_DELAY)
|
|
47
|
+
};
|
|
48
|
+
this.reconnectCallback = reconnectCallback;
|
|
49
|
+
this.onAttempt = callbacks.onAttempt || (() => {
|
|
50
|
+
});
|
|
51
|
+
this.onSuccess = callbacks.onSuccess || (() => {
|
|
52
|
+
});
|
|
53
|
+
this.onFail = callbacks.onFail || (() => {
|
|
54
|
+
});
|
|
55
|
+
this.onMaxAttemptsExceeded = callbacks.onMaxAttemptsExceeded || (() => {
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 启动重连过程
|
|
60
|
+
*/
|
|
61
|
+
startReconnect() {
|
|
62
|
+
if (this.isReconnecting || !this.options.enabled) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.isReconnecting = true;
|
|
66
|
+
this.attempts = 0;
|
|
67
|
+
this.scheduleReconnect();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 停止重连过程
|
|
71
|
+
*/
|
|
72
|
+
stopReconnect() {
|
|
73
|
+
this.isReconnecting = false;
|
|
74
|
+
if (this.timer) {
|
|
75
|
+
clearTimeout(this.timer);
|
|
76
|
+
this.timer = null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 获取当前重连尝试次数
|
|
81
|
+
*/
|
|
82
|
+
getReconnectAttempts() {
|
|
83
|
+
return this.attempts;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 获取当前是否正在重连
|
|
87
|
+
*/
|
|
88
|
+
isActive() {
|
|
89
|
+
return this.isReconnecting;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 重置重连状态
|
|
93
|
+
*/
|
|
94
|
+
reset() {
|
|
95
|
+
this.stopReconnect();
|
|
96
|
+
this.attempts = 0;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 安排下一次重连尝试
|
|
100
|
+
*/
|
|
101
|
+
scheduleReconnect() {
|
|
102
|
+
if (!this.isReconnecting) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (this.options.attempts !== void 0 && this.attempts >= this.options.attempts) {
|
|
106
|
+
this.isReconnecting = false;
|
|
107
|
+
this.onMaxAttemptsExceeded();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const delay = this.getReconnectDelay();
|
|
111
|
+
this.timer = setTimeout(() => {
|
|
112
|
+
this.attempts++;
|
|
113
|
+
this.onAttempt(this.attempts);
|
|
114
|
+
this.executeReconnect().then((success) => {
|
|
115
|
+
if (success) {
|
|
116
|
+
this.isReconnecting = false;
|
|
117
|
+
this.onSuccess();
|
|
118
|
+
} else {
|
|
119
|
+
this.scheduleReconnect();
|
|
120
|
+
}
|
|
121
|
+
}).catch((error) => {
|
|
122
|
+
this.onFail(error);
|
|
123
|
+
this.scheduleReconnect();
|
|
124
|
+
});
|
|
125
|
+
}, delay);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 执行重连操作
|
|
129
|
+
*/
|
|
130
|
+
async executeReconnect() {
|
|
131
|
+
try {
|
|
132
|
+
return await this.reconnectCallback();
|
|
133
|
+
} catch (error) {
|
|
134
|
+
this.onFail(error instanceof Error ? error : new Error("Reconnect failed"));
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 计算重连延迟时间
|
|
140
|
+
* 支持指数退避算法,增加随机抖动
|
|
141
|
+
*/
|
|
142
|
+
getReconnectDelay() {
|
|
143
|
+
const { delay, delayMax, jitter } = this.options;
|
|
144
|
+
let calculatedDelay = delay;
|
|
145
|
+
if (this.attempts > 0) {
|
|
146
|
+
calculatedDelay = Math.min(delayMax || Infinity, delay * Math.pow(1.5, this.attempts - 1));
|
|
147
|
+
}
|
|
148
|
+
if (jitter) {
|
|
149
|
+
calculatedDelay = Math.random() * calculatedDelay;
|
|
150
|
+
}
|
|
151
|
+
return Math.max(import_constants.MIN_RECONNECTION_DELAY, Math.floor(calculatedDelay));
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
155
|
+
0 && (module.exports = {
|
|
156
|
+
ReconnectManager
|
|
157
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { SocketOptions, SocketStatus } from "./types";
|
|
2
|
+
import { SocketMonitor, SocketMonitorOptions } from "./monitor";
|
|
3
|
+
/**
|
|
4
|
+
* Socket主类
|
|
5
|
+
* 负责管理WebSocket连接、消息收发、事件处理、心跳检测和断线重连
|
|
6
|
+
*/
|
|
7
|
+
export declare class Socket {
|
|
8
|
+
private ws;
|
|
9
|
+
private url;
|
|
10
|
+
private options;
|
|
11
|
+
private status;
|
|
12
|
+
private eventHandlers;
|
|
13
|
+
private heartbeatManager;
|
|
14
|
+
private reconnectManager;
|
|
15
|
+
private monitor;
|
|
16
|
+
private messageIdCounter;
|
|
17
|
+
/**
|
|
18
|
+
* 创建Socket实例
|
|
19
|
+
* @param options Socket配置选项
|
|
20
|
+
*/
|
|
21
|
+
constructor(options: SocketOptions);
|
|
22
|
+
/**
|
|
23
|
+
* 建立WebSocket连接
|
|
24
|
+
*/
|
|
25
|
+
connect(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* 关闭WebSocket连接
|
|
28
|
+
* @param isManual 是否手动关闭
|
|
29
|
+
*/
|
|
30
|
+
disconnect(isManual?: boolean): void;
|
|
31
|
+
/**
|
|
32
|
+
* 发送消息到服务器
|
|
33
|
+
* @param event 事件名称
|
|
34
|
+
* @param data 消息数据
|
|
35
|
+
* @param id 消息ID(可选,默认自动生成)
|
|
36
|
+
*/
|
|
37
|
+
send(type: string, data?: any, id?: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* 发送原始消息
|
|
40
|
+
* @param message 消息对象
|
|
41
|
+
*/
|
|
42
|
+
private sendRaw;
|
|
43
|
+
/**
|
|
44
|
+
* 注册事件监听器
|
|
45
|
+
* @param event 事件名称
|
|
46
|
+
* @param handler 事件处理函数
|
|
47
|
+
*/
|
|
48
|
+
on(event: string, handler: (...args: any[]) => void): void;
|
|
49
|
+
/**
|
|
50
|
+
* 移除事件监听器
|
|
51
|
+
* @param event 事件名称
|
|
52
|
+
* @param handler 事件处理函数(可选,不提供则移除所有该事件的处理函数)
|
|
53
|
+
*/
|
|
54
|
+
off(event: string, handler?: (...args: any[]) => void): void;
|
|
55
|
+
/**
|
|
56
|
+
* 触发事件
|
|
57
|
+
* @param event 事件名称
|
|
58
|
+
* @param args 事件参数
|
|
59
|
+
*/
|
|
60
|
+
private emit;
|
|
61
|
+
/**
|
|
62
|
+
* 获取当前连接状态
|
|
63
|
+
*/
|
|
64
|
+
getStatus(): SocketStatus;
|
|
65
|
+
/**
|
|
66
|
+
* 获取当前状态描述
|
|
67
|
+
*/
|
|
68
|
+
getStatusText(): string;
|
|
69
|
+
/**
|
|
70
|
+
* 检查是否已连接
|
|
71
|
+
*/
|
|
72
|
+
isConnected(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* 设置连接状态
|
|
75
|
+
*/
|
|
76
|
+
private setStatus;
|
|
77
|
+
/**
|
|
78
|
+
* 设置WebSocket事件监听器
|
|
79
|
+
*/
|
|
80
|
+
private setupWebSocketListeners;
|
|
81
|
+
/**
|
|
82
|
+
* 处理接收到的消息
|
|
83
|
+
*/
|
|
84
|
+
private handleMessage;
|
|
85
|
+
/**
|
|
86
|
+
* 处理连接关闭
|
|
87
|
+
*/
|
|
88
|
+
private handleConnectionClosed;
|
|
89
|
+
/**
|
|
90
|
+
* 处理连接失败
|
|
91
|
+
*/
|
|
92
|
+
private handleConnectionFailure;
|
|
93
|
+
/**
|
|
94
|
+
* 处理心跳响应
|
|
95
|
+
*/
|
|
96
|
+
private handleHeartbeatResponse;
|
|
97
|
+
/**
|
|
98
|
+
* 初始化心跳检测
|
|
99
|
+
*/
|
|
100
|
+
private initHeartbeat;
|
|
101
|
+
/**
|
|
102
|
+
* 初始化重连管理
|
|
103
|
+
*/
|
|
104
|
+
private initReconnect;
|
|
105
|
+
/**
|
|
106
|
+
* 开始重连过程
|
|
107
|
+
*/
|
|
108
|
+
private startReconnection;
|
|
109
|
+
/**
|
|
110
|
+
* 生成消息ID
|
|
111
|
+
*/
|
|
112
|
+
private generateMessageId;
|
|
113
|
+
/**
|
|
114
|
+
* 启用监控功能
|
|
115
|
+
* @param options 监控配置选项
|
|
116
|
+
*/
|
|
117
|
+
enableMonitoring(options?: SocketMonitorOptions): SocketMonitor;
|
|
118
|
+
/**
|
|
119
|
+
* 禁用监控功能
|
|
120
|
+
*/
|
|
121
|
+
disableMonitoring(): void;
|
|
122
|
+
/**
|
|
123
|
+
* 获取监控器实例
|
|
124
|
+
*/
|
|
125
|
+
getMonitor(): SocketMonitor | null;
|
|
126
|
+
/**
|
|
127
|
+
* 释放资源
|
|
128
|
+
*/
|
|
129
|
+
destroy(): void;
|
|
130
|
+
}
|