@ives_xxz/framework 2.1.32 → 2.1.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/package.json +4 -2
- package/service/socket/FWSocket.ts +36 -21
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ives_xxz/framework",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.33",
|
|
4
4
|
"description": "cocoscreator 2.x mvc framework",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"keywords": [
|
|
6
|
+
"keywords": [
|
|
7
|
+
"123456"
|
|
8
|
+
],
|
|
7
9
|
"author": "ives",
|
|
8
10
|
"license": "ISC"
|
|
9
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FWSystemConfig } from
|
|
1
|
+
import { FWSystemConfig } from "../../config/FWSystemConfig";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* TODO 犹豫socket没有改版暂时已老的cmd字符串映射方式做,后期优化
|
|
@@ -106,10 +106,14 @@ export default class FWSocket extends FW.Service implements FW.Socket {
|
|
|
106
106
|
this.heartInternal = config?.heartInternal || defaultConfig.heartInternal;
|
|
107
107
|
this.heartTimeout = config?.heartTimeout || defaultConfig.heartTimeout;
|
|
108
108
|
this.heartWeakTime = config?.heartWeakTime || defaultConfig.heartWeakTime;
|
|
109
|
-
this.maxReconnectTimes =
|
|
110
|
-
|
|
111
|
-
this.
|
|
112
|
-
|
|
109
|
+
this.maxReconnectTimes =
|
|
110
|
+
config?.maxReconnectTimes || defaultConfig.maxReconnectTimes;
|
|
111
|
+
this.reconnectInternal =
|
|
112
|
+
config?.reconnectInternal || defaultConfig.reconnectInternal;
|
|
113
|
+
this.protocolSymbol =
|
|
114
|
+
config?.protocolSymbol || defaultConfig.protocolSymbol;
|
|
115
|
+
this.protocolPollingTime =
|
|
116
|
+
config?.protocolPollingTime || defaultConfig.protocolPollingTime;
|
|
113
117
|
|
|
114
118
|
this.promiseProxy = {
|
|
115
119
|
promise: undefined,
|
|
@@ -123,7 +127,7 @@ export default class FWSocket extends FW.Service implements FW.Socket {
|
|
|
123
127
|
|
|
124
128
|
return this.promiseProxy;
|
|
125
129
|
} catch (e) {
|
|
126
|
-
FW.Log.error(
|
|
130
|
+
FW.Log.error("创建socket失败:", e);
|
|
127
131
|
}
|
|
128
132
|
}
|
|
129
133
|
/**
|
|
@@ -165,6 +169,7 @@ export default class FWSocket extends FW.Service implements FW.Socket {
|
|
|
165
169
|
*/
|
|
166
170
|
public close() {
|
|
167
171
|
this.clear();
|
|
172
|
+
FW.Entry.timeMgr.unSchedule(this);
|
|
168
173
|
FW.Entry.socketMgr.closeSocket(this);
|
|
169
174
|
}
|
|
170
175
|
|
|
@@ -200,16 +205,22 @@ export default class FWSocket extends FW.Service implements FW.Socket {
|
|
|
200
205
|
this.socket?.close();
|
|
201
206
|
this.socket = null;
|
|
202
207
|
|
|
203
|
-
this.createSocket(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
this.createSocket(
|
|
209
|
+
this.address,
|
|
210
|
+
this.tag,
|
|
211
|
+
this.socketSender,
|
|
212
|
+
this.socketHandle,
|
|
213
|
+
{
|
|
214
|
+
heartInternal: this.heartInternal,
|
|
215
|
+
heartTimeout: this.heartTimeout,
|
|
216
|
+
heartWeakTime: this.heartWeakTime,
|
|
217
|
+
maxReconnectTimes: this.maxReconnectTimes,
|
|
218
|
+
reconnectInternal: this.reconnectInternal,
|
|
219
|
+
protocolSymbol: this.protocolSymbol,
|
|
220
|
+
protocolPollingTime: this.protocolPollingTime,
|
|
221
|
+
certificate: this.certificate,
|
|
222
|
+
},
|
|
223
|
+
);
|
|
213
224
|
}
|
|
214
225
|
|
|
215
226
|
async send(msg: string) {
|
|
@@ -219,7 +230,8 @@ export default class FWSocket extends FW.Service implements FW.Socket {
|
|
|
219
230
|
const protocolKey = this.socketSender.getProtocolKey?.(msg);
|
|
220
231
|
if (protocolKey) {
|
|
221
232
|
const symbol = Symbol(protocolKey);
|
|
222
|
-
const registry =
|
|
233
|
+
const registry =
|
|
234
|
+
this.protocolRegistry.get(protocolKey) || new Set<Symbol>();
|
|
223
235
|
const protocolPolling: FW.ProtocolPolling = {
|
|
224
236
|
msg: msg,
|
|
225
237
|
schedule: FW.Entry.timeMgr.schedule(
|
|
@@ -240,7 +252,7 @@ export default class FWSocket extends FW.Service implements FW.Socket {
|
|
|
240
252
|
|
|
241
253
|
/** 连接打开 */
|
|
242
254
|
private onSocketOpen() {
|
|
243
|
-
FW.Log.debug(
|
|
255
|
+
FW.Log.debug("on open!");
|
|
244
256
|
FW.Entry.timeMgr.unSchedule(this);
|
|
245
257
|
this.reconnectTimes = 0;
|
|
246
258
|
this.sendHeartTimestamp = 0;
|
|
@@ -284,12 +296,15 @@ export default class FWSocket extends FW.Service implements FW.Socket {
|
|
|
284
296
|
|
|
285
297
|
/** socket关闭 */
|
|
286
298
|
private onSocketClose() {
|
|
287
|
-
FW.Log.debug(
|
|
299
|
+
FW.Log.debug("on close!");
|
|
288
300
|
this.socketHandle?.onClose?.();
|
|
289
301
|
FW.Entry.timeMgr.scheduleOnce(
|
|
290
302
|
() => {
|
|
291
|
-
if (
|
|
292
|
-
|
|
303
|
+
if (
|
|
304
|
+
this.getReadyState() == WebSocket.CLOSING ||
|
|
305
|
+
this.getReadyState() == WebSocket.CLOSED
|
|
306
|
+
) {
|
|
307
|
+
FW.Log.debug("on close!");
|
|
293
308
|
this.reconnect();
|
|
294
309
|
}
|
|
295
310
|
},
|