@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 CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "2.1.32",
3
+ "version": "2.1.33",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
- "keywords": ["123456"],
6
+ "keywords": [
7
+ "123456"
8
+ ],
7
9
  "author": "ives",
8
10
  "license": "ISC"
9
11
  }
@@ -1,4 +1,4 @@
1
- import { FWSystemConfig } from '../../config/FWSystemConfig';
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 = config?.maxReconnectTimes || defaultConfig.maxReconnectTimes;
110
- this.reconnectInternal = config?.reconnectInternal || defaultConfig.reconnectInternal;
111
- this.protocolSymbol = config?.protocolSymbol || defaultConfig.protocolSymbol;
112
- this.protocolPollingTime = config?.protocolPollingTime || defaultConfig.protocolPollingTime;
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('创建socket失败:', e);
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(this.address, this.tag, this.socketSender, this.socketHandle, {
204
- heartInternal: this.heartInternal,
205
- heartTimeout: this.heartTimeout,
206
- heartWeakTime: this.heartWeakTime,
207
- maxReconnectTimes: this.maxReconnectTimes,
208
- reconnectInternal: this.reconnectInternal,
209
- protocolSymbol: this.protocolSymbol,
210
- protocolPollingTime: this.protocolPollingTime,
211
- certificate: this.certificate,
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 = this.protocolRegistry.get(protocolKey) || new Set<Symbol>();
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('on open!');
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('on close!');
299
+ FW.Log.debug("on close!");
288
300
  this.socketHandle?.onClose?.();
289
301
  FW.Entry.timeMgr.scheduleOnce(
290
302
  () => {
291
- if (this.getReadyState() == WebSocket.CLOSING || this.getReadyState() == WebSocket.CLOSED) {
292
- FW.Log.debug('on close!');
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
  },