@ives_xxz/framework 1.2.18 → 1.2.20
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/FW.d.ts +6 -0
- package/config/FWSystemConfig.ts +1 -0
- package/manager/FWLayerManager.ts +8 -0
- package/package.json +1 -1
- package/service/socket/FWSocket.ts +22 -11
package/FW.d.ts
CHANGED
|
@@ -219,6 +219,11 @@ declare namespace FW {
|
|
|
219
219
|
socket: FW.Socket;
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
+
type ProtocolPolling = {
|
|
223
|
+
msg: string;
|
|
224
|
+
schedule: TimerSchedule;
|
|
225
|
+
};
|
|
226
|
+
|
|
222
227
|
type Socket = {
|
|
223
228
|
public onDestroy(): void;
|
|
224
229
|
/**
|
|
@@ -275,6 +280,7 @@ declare namespace FW {
|
|
|
275
280
|
maxReconnectTimes: number;
|
|
276
281
|
reconnectInternal: number;
|
|
277
282
|
protocolSymbol: Symbol;
|
|
283
|
+
protocolPollingTime: number;
|
|
278
284
|
};
|
|
279
285
|
|
|
280
286
|
/**
|
package/config/FWSystemConfig.ts
CHANGED
|
@@ -138,6 +138,7 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
|
|
|
138
138
|
layerData.controllerName = ctrName;
|
|
139
139
|
|
|
140
140
|
this.layerMap.set(ctrName, layerData);
|
|
141
|
+
FWLog.debug('打开Layer -> ', layerData?.controllerName, this.layerMap.has(ctrName));
|
|
141
142
|
|
|
142
143
|
if (this.layerRegistry.has(data.type)) {
|
|
143
144
|
return this.layerMap.get(ctrName).controllerProxy as Ctr;
|
|
@@ -300,6 +301,9 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
|
|
|
300
301
|
*/
|
|
301
302
|
displayLayer<Ctr extends FW.LayerController = FW.LayerController>(ctr: Ctr): Ctr {
|
|
302
303
|
const layerData = ctr.layerData;
|
|
304
|
+
|
|
305
|
+
FWLog.debug('关闭Layer -> ', layerData?.controllerName);
|
|
306
|
+
|
|
303
307
|
if (!this.layerMap.has(layerData.controllerName)) {
|
|
304
308
|
FWLog.warn(`display layer failed,layer name : ${layerData.layerName}`);
|
|
305
309
|
return;
|
|
@@ -399,6 +403,8 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
|
|
|
399
403
|
this.notifyExternalRefUpdates(ctr.layerData);
|
|
400
404
|
}
|
|
401
405
|
|
|
406
|
+
FWLog.debug('closeLayer', layerData.controllerName);
|
|
407
|
+
|
|
402
408
|
this.layerMap.delete(layerData.controllerName);
|
|
403
409
|
this.layerRegistry.delete(ctr.layerData.controllerConstructor);
|
|
404
410
|
|
|
@@ -517,6 +523,7 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
|
|
|
517
523
|
}
|
|
518
524
|
|
|
519
525
|
public clear() {
|
|
526
|
+
FWLog.debug('调用clear');
|
|
520
527
|
this.layerQueue = new FWQueue();
|
|
521
528
|
this.layerStack = [];
|
|
522
529
|
this.layerRegistry = new Set<new () => FW.LayerController>();
|
|
@@ -525,6 +532,7 @@ export class FWLayerManager extends FWManager implements FW.LayerManager {
|
|
|
525
532
|
}
|
|
526
533
|
|
|
527
534
|
public onDestroy(): void {
|
|
535
|
+
FWLog.debug('调用onDestroy');
|
|
528
536
|
this.layerMap.clear();
|
|
529
537
|
this.layerMap = null;
|
|
530
538
|
this.layerQueue = null;
|
package/package.json
CHANGED
|
@@ -39,10 +39,12 @@ export default class FWSocket implements FW.Socket {
|
|
|
39
39
|
private promiseProxy: FW.SocketPromiseProxy;
|
|
40
40
|
/** 协议符号 */
|
|
41
41
|
private protocolSymbol: FW.Symbol;
|
|
42
|
+
/** 协议轮询时间 */
|
|
43
|
+
private protocolPollingTime: number;
|
|
42
44
|
/** 协议注册表 */
|
|
43
45
|
private protocolRegistry: Map<string, Set<Symbol>>;
|
|
44
46
|
/** 协议符号容器 */
|
|
45
|
-
private protocolContainer: Map<Symbol,
|
|
47
|
+
private protocolContainer: Map<Symbol, FW.ProtocolPolling>;
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* 消息事件列表
|
|
@@ -56,7 +58,7 @@ export default class FWSocket implements FW.Socket {
|
|
|
56
58
|
|
|
57
59
|
public initialize(): void {
|
|
58
60
|
this.messageEvents = cc.js.createMap();
|
|
59
|
-
this.protocolContainer = new Map<Symbol,
|
|
61
|
+
this.protocolContainer = new Map<Symbol, FW.ProtocolPolling>();
|
|
60
62
|
this.protocolRegistry = new Map<string, Set<Symbol>>();
|
|
61
63
|
this.reconnectTimes = 0;
|
|
62
64
|
}
|
|
@@ -96,6 +98,7 @@ export default class FWSocket implements FW.Socket {
|
|
|
96
98
|
this.maxReconnectTimes = config?.maxReconnectTimes || defaultConfig.maxReconnectTimes;
|
|
97
99
|
this.reconnectInternal = config?.reconnectInternal || defaultConfig.reconnectInternal;
|
|
98
100
|
this.protocolSymbol = config?.protocolSymbol || defaultConfig.protocolSymbol;
|
|
101
|
+
this.protocolPollingTime = config?.protocolPollingTime || defaultConfig.protocolPollingTime;
|
|
99
102
|
|
|
100
103
|
this.promiseProxy = {
|
|
101
104
|
promise: undefined,
|
|
@@ -192,10 +195,11 @@ export default class FWSocket implements FW.Socket {
|
|
|
192
195
|
maxReconnectTimes: this.maxReconnectTimes,
|
|
193
196
|
reconnectInternal: this.reconnectInternal,
|
|
194
197
|
protocolSymbol: this.protocolSymbol,
|
|
198
|
+
protocolPollingTime: this.protocolPollingTime,
|
|
195
199
|
});
|
|
196
200
|
}
|
|
197
201
|
|
|
198
|
-
async send(msg:
|
|
202
|
+
async send(msg: string) {
|
|
199
203
|
if (this.getReadyState() != WebSocket.OPEN) return;
|
|
200
204
|
if (this.isPausedMessageHandle) return;
|
|
201
205
|
if (!(await this.sender.onHeart?.(msg))) {
|
|
@@ -203,8 +207,19 @@ export default class FWSocket implements FW.Socket {
|
|
|
203
207
|
if (protocolKey) {
|
|
204
208
|
const symbol = Symbol(protocolKey);
|
|
205
209
|
const registry = this.protocolRegistry.get(protocolKey) || new Set<Symbol>();
|
|
210
|
+
const protocolPolling: FW.ProtocolPolling = {
|
|
211
|
+
msg: msg,
|
|
212
|
+
schedule: FW.Entry.timeMgr.schedule(
|
|
213
|
+
() => {
|
|
214
|
+
this.sendMessage(msg);
|
|
215
|
+
},
|
|
216
|
+
this.protocolPollingTime,
|
|
217
|
+
cc.macro.REPEAT_FOREVER,
|
|
218
|
+
this,
|
|
219
|
+
),
|
|
220
|
+
};
|
|
206
221
|
this.protocolRegistry.set(protocolKey, registry.add(symbol));
|
|
207
|
-
this.protocolContainer.set(symbol,
|
|
222
|
+
this.protocolContainer.set(symbol, protocolPolling);
|
|
208
223
|
}
|
|
209
224
|
}
|
|
210
225
|
this.sendMessage(msg);
|
|
@@ -234,13 +249,6 @@ export default class FWSocket implements FW.Socket {
|
|
|
234
249
|
}
|
|
235
250
|
}
|
|
236
251
|
this.sendHeart();
|
|
237
|
-
|
|
238
|
-
if (this.protocolContainer.size > 0) {
|
|
239
|
-
this.protocolContainer?.forEach((msg) => {
|
|
240
|
-
FWLog.send('协议容器轮询消息 -> ', msg);
|
|
241
|
-
this.sendMessage(msg);
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
252
|
},
|
|
245
253
|
this.heartInternal / 1000,
|
|
246
254
|
cc.macro.REPEAT_FOREVER,
|
|
@@ -305,9 +313,12 @@ export default class FWSocket implements FW.Socket {
|
|
|
305
313
|
|
|
306
314
|
if (symbolSet && symbolSet.size > 0) {
|
|
307
315
|
const [symbol] = symbolSet;
|
|
316
|
+
const protocolPolling = this.protocolContainer.get(symbol);
|
|
308
317
|
|
|
309
318
|
symbolSet.delete(symbol);
|
|
310
319
|
|
|
320
|
+
protocolPolling.schedule.unSchedule();
|
|
321
|
+
|
|
311
322
|
this.protocolContainer.delete(symbol);
|
|
312
323
|
|
|
313
324
|
if (symbolSet.size === 0) {
|