@ives_xxz/framework 1.2.14 → 1.2.17

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 CHANGED
@@ -244,6 +244,10 @@ declare namespace FW {
244
244
  * 关闭连接
245
245
  */
246
246
  close();
247
+ /**
248
+ * 清理
249
+ */
250
+ clear();
247
251
  /**
248
252
  * 暂停消息处理
249
253
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "1.2.14",
3
+ "version": "1.2.17",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -74,9 +74,9 @@ export default class FWSocket implements FW.Socket {
74
74
  this.tag = tag;
75
75
  this.address = address;
76
76
 
77
+ this.clear();
78
+
77
79
  this.messageEvents = {};
78
- this.protocolContainer.clear();
79
- this.protocolRegistry.clear();
80
80
  this.sendHeartTimestamp = 0;
81
81
  this.receiveTimeStamp = new Date().getTime();
82
82
 
@@ -149,7 +149,7 @@ export default class FWSocket implements FW.Socket {
149
149
  * 关闭连接
150
150
  */
151
151
  public close() {
152
- this.protocolContainer.clear();
152
+ this.clear();
153
153
  FW.Entry.socketMgr.closeSocket(this);
154
154
  }
155
155
 
@@ -165,6 +165,11 @@ export default class FWSocket implements FW.Socket {
165
165
  return this.getReadyState() === WebSocket.CONNECTING;
166
166
  }
167
167
 
168
+ public clear() {
169
+ this.protocolContainer.clear();
170
+ this.protocolRegistry.clear();
171
+ }
172
+
168
173
  reconnect(force?: boolean) {
169
174
  if (force) this.reconnectTimes = 0;
170
175
 
@@ -175,6 +180,7 @@ export default class FWSocket implements FW.Socket {
175
180
  this.handle?.onTimeout?.();
176
181
  return;
177
182
  }
183
+ this.clear();
178
184
 
179
185
  this.socket?.close();
180
186
  this.socket = null;
@@ -270,6 +276,7 @@ export default class FWSocket implements FW.Socket {
270
276
  this,
271
277
  );
272
278
  }
279
+
273
280
  /** 消息处理 */
274
281
  private async onSocketMessage(originalMsg: any) {
275
282
  const msg = await this.handle.onBeforeReceivingMessage(originalMsg);