@ives_xxz/framework 2.3.6 → 2.3.8

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.
@@ -1,8 +1,11 @@
1
- import { FWManager } from './FWManager';
1
+ import { FWManager } from "./FWManager";
2
2
 
3
- const TEMOTE_ASSET = 'remote-asset';
3
+ const TEMOTE_ASSET = "remote-asset";
4
4
 
5
- export default class FWHotUpdateManager extends FWManager implements FW.HotUpdateManager {
5
+ export default class FWHotUpdateManager
6
+ extends FWManager
7
+ implements FW.HotUpdateManager
8
+ {
6
9
  private listener: FW.HotUpdateListener;
7
10
  private assetMgr: any;
8
11
  private storePath: string;
@@ -14,19 +17,29 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
14
17
 
15
18
  setListener(listener: FW.HotUpdateListener): FW.HotUpdateManager {
16
19
  this.listener = listener;
17
- FW.Log.debug('热更新监听设置');
20
+ FW.Log.debug("热更新监听设置");
18
21
  return this;
19
22
  }
20
23
 
21
24
  public update(localManifest: cc.Asset) {
22
25
  if (!localManifest) {
23
- FW.Log.error('没有找到本地Manifest文件!');
26
+ FW.Log.error("没有找到本地Manifest文件!");
24
27
  return;
25
28
  }
26
- FW.Log.debug('开始热更新流程');
29
+
30
+ const loadManifest = jsb.fileUtils.getStringFromFile(
31
+ localManifest.nativeUrl,
32
+ );
33
+ const manifestObject = JSON.parse(loadManifest);
34
+
35
+ FW.Log.debug("开始热更新流程:", manifestObject?.packageUrl);
27
36
  this.localManifest = localManifest;
28
- this.storePath = `${jsb.fileUtils ? jsb.fileUtils.getWritablePath() : '/'}${TEMOTE_ASSET}`;
29
- this.assetMgr = new jsb.AssetsManager('', this.storePath, this.versionCompareHandle.bind(this));
37
+ this.storePath = `${jsb.fileUtils ? jsb.fileUtils.getWritablePath() : "/"}${TEMOTE_ASSET}`;
38
+ this.assetMgr = new jsb.AssetsManager(
39
+ "",
40
+ this.storePath,
41
+ this.versionCompareHandle.bind(this),
42
+ );
30
43
  this.assetMgr.setVerifyCallback(function (path: string, asset: any) {
31
44
  const compressed = asset.compressed;
32
45
  const expectedMD5 = asset.md5;
@@ -41,16 +54,19 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
41
54
  this.checkHotUpdate();
42
55
  }
43
56
 
44
- private versionCompareHandle(currentVersion: string, newVersion: string): number {
45
- FW.Log.debug('版本比较', currentVersion, newVersion);
57
+ private versionCompareHandle(
58
+ currentVersion: string,
59
+ newVersion: string,
60
+ ): number {
61
+ FW.Log.debug("版本比较", currentVersion, newVersion);
46
62
  this.currentVersion = currentVersion;
47
63
  this.newVersion = newVersion;
48
64
  this.listener.versionCompareHandle(this.currentVersion, this.newVersion);
49
- var vA = currentVersion.split('.');
50
- var vB = newVersion.split('.');
65
+ var vA = currentVersion.split(".");
66
+ var vB = newVersion.split(".");
51
67
  for (var i = 0; i < vA.length; ++i) {
52
68
  var a = parseInt(vA[i]);
53
- var b = parseInt(vB[i] || '0');
69
+ var b = parseInt(vB[i] || "0");
54
70
  if (a === b) {
55
71
  continue;
56
72
  } else {
@@ -73,7 +89,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
73
89
  }
74
90
 
75
91
  private checkHotUpdate() {
76
- FW.Log.debug('checkHotUpdate1', this.isUpdate);
92
+ FW.Log.debug("checkHotUpdate1", this.isUpdate);
77
93
  if (this.isUpdate) {
78
94
  return;
79
95
  }
@@ -81,17 +97,26 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
81
97
  this.assetMgr.loadLocalManifest(this.localManifest.nativeUrl);
82
98
  }
83
99
 
84
- FW.Log.debug('checkHotUpdate3', this.assetMgr.getLocalManifest());
100
+ FW.Log.debug("checkHotUpdate3", this.assetMgr.getLocalManifest());
85
101
 
86
- FW.Log.debug('checkHotUpdate4', this.assetMgr.getLocalManifest().isLoaded());
102
+ FW.Log.debug(
103
+ "checkHotUpdate4",
104
+ this.assetMgr.getLocalManifest().isLoaded(),
105
+ );
87
106
 
88
- if (!this.assetMgr.getLocalManifest() || !this.assetMgr.getLocalManifest().isLoaded()) {
89
- FW.Log.debug('本地manifest未加载,尝试重新加载');
107
+ if (
108
+ !this.assetMgr.getLocalManifest() ||
109
+ !this.assetMgr.getLocalManifest().isLoaded()
110
+ ) {
111
+ FW.Log.debug("本地manifest未加载,尝试重新加载");
90
112
  this.reloadLocalManifest();
91
113
 
92
114
  // 如果仍然无法加载,则返回
93
- if (!this.assetMgr.getLocalManifest() || !this.assetMgr.getLocalManifest().isLoaded()) {
94
- FW.Log.error('无法加载本地manifest文件');
115
+ if (
116
+ !this.assetMgr.getLocalManifest() ||
117
+ !this.assetMgr.getLocalManifest().isLoaded()
118
+ ) {
119
+ FW.Log.error("无法加载本地manifest文件");
95
120
  return;
96
121
  }
97
122
  }
@@ -107,38 +132,41 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
107
132
  if (jsb.fileUtils.isFileExist(updatedManifestPath)) {
108
133
  this.assetMgr.loadLocalManifest(updatedManifestPath);
109
134
 
110
- if (this.assetMgr.getLocalManifest() && this.assetMgr.getLocalManifest().isLoaded()) {
111
- FW.Log.debug('本地manifest重新加载成功');
135
+ if (
136
+ this.assetMgr.getLocalManifest() &&
137
+ this.assetMgr.getLocalManifest().isLoaded()
138
+ ) {
139
+ FW.Log.debug("本地manifest重新加载成功");
112
140
  this.localManifest = this.assetMgr.getLocalManifest();
113
141
  } else {
114
- FW.Log.error('本地manifest重新加载失败');
142
+ FW.Log.error("本地manifest重新加载失败");
115
143
  }
116
144
  } else {
117
- FW.Log.error('更新后的manifest文件不存在:', updatedManifestPath);
145
+ FW.Log.error("更新后的manifest文件不存在:", updatedManifestPath);
118
146
  }
119
147
  } catch (error) {
120
- FW.Log.error('重新加载本地manifest时出错:', error);
148
+ FW.Log.error("重新加载本地manifest时出错:", error);
121
149
  }
122
150
  }
123
151
 
124
152
  private checkEventHandle(event: any) {
125
153
  const code = event.getEventCode();
126
- FW.Log.debug('checkEvent getEventCode -> ', code);
154
+ FW.Log.debug("checkEvent getEventCode -> ", code);
127
155
  switch (code) {
128
156
  case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST:
129
- FW.Log.debug('checkEvent getEventCode -> ', 'ERROR_NO_LOCAL_MANIFEST');
157
+ FW.Log.debug("checkEvent getEventCode -> ", "ERROR_NO_LOCAL_MANIFEST");
130
158
  break;
131
159
  case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST:
132
- FW.Log.debug('checkEvent getEventCode -> ', 'ERROR_DOWNLOAD_MANIFEST');
160
+ FW.Log.debug("checkEvent getEventCode -> ", "ERROR_DOWNLOAD_MANIFEST");
133
161
  break;
134
162
  case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST:
135
- FW.Log.debug('checkEvent getEventCode -> ', 'ERROR_PARSE_MANIFEST');
163
+ FW.Log.debug("checkEvent getEventCode -> ", "ERROR_PARSE_MANIFEST");
136
164
  break;
137
165
  case jsb.EventAssetsManager.ALREADY_UP_TO_DATE:
138
- FW.Log.debug('checkEvent getEventCode -> ', 'ALREADY_UP_TO_DATE');
166
+ FW.Log.debug("checkEvent getEventCode -> ", "ALREADY_UP_TO_DATE");
139
167
  break;
140
168
  case jsb.EventAssetsManager.NEW_VERSION_FOUND:
141
- FW.Log.debug('checkEvent getEventCode -> ', 'NEW_VERSION_FOUND');
169
+ FW.Log.debug("checkEvent getEventCode -> ", "NEW_VERSION_FOUND");
142
170
  break;
143
171
  default:
144
172
  return;
@@ -148,7 +176,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
148
176
  this.assetMgr.setEventCallback(null!);
149
177
  this.isUpdate = false;
150
178
  FW.Log.debug(
151
- 'isFind New Version -> ',
179
+ "isFind New Version -> ",
152
180
  event.getEventCode() == jsb.EventAssetsManager.NEW_VERSION_FOUND,
153
181
  );
154
182
  if (event.getEventCode() == jsb.EventAssetsManager.NEW_VERSION_FOUND) {
@@ -157,11 +185,11 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
157
185
  }
158
186
 
159
187
  private hotUpdate() {
160
- FW.Log.debug('start hotUpdate ->', this.assetMgr, this.isUpdate);
188
+ FW.Log.debug("start hotUpdate ->", this.assetMgr, this.isUpdate);
161
189
  if (this.assetMgr && !this.isUpdate) {
162
190
  this.assetMgr.setEventCallback(this.updateEventHandle.bind(this));
163
191
  FW.Log.debug(
164
- 'assetMgr state ->',
192
+ "assetMgr state ->",
165
193
  this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED,
166
194
  );
167
195
  if (this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED) {
@@ -180,20 +208,20 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
180
208
  let totalFiles: number = 0;
181
209
  let downloadedBytes: number = 0;
182
210
  let totalBytes: number = 0;
183
- let convertDownloadedBytes: string = '';
184
- let convertTotalBytes: string = '';
211
+ let convertDownloadedBytes: string = "";
212
+ let convertTotalBytes: string = "";
185
213
  const code = event.getEventCode();
186
214
  const msg = event.getMessage();
187
- FW.Log.debug('updateEvent getEventCode -> ', code);
188
- let str = '';
215
+ FW.Log.debug("updateEvent getEventCode -> ", code);
216
+ let str = "";
189
217
  switch (code) {
190
218
  case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST:
191
219
  failed = true;
192
- str = 'ERROR_NO_LOCAL_MANIFEST';
220
+ str = "ERROR_NO_LOCAL_MANIFEST";
193
221
  break;
194
222
  case jsb.EventAssetsManager.UPDATE_PROGRESSION:
195
- str = 'UPDATE_PROGRESSION';
196
- FW.Log.debug('updateEvent percent -> ', event.getPercent());
223
+ str = "UPDATE_PROGRESSION";
224
+ FW.Log.debug("updateEvent percent -> ", event.getPercent());
197
225
  if (event.getPercent() > 0) {
198
226
  downloadedFiles = event.getDownloadedFiles();
199
227
  totalFiles = event.getTotalFiles();
@@ -203,27 +231,27 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
203
231
  convertTotalBytes = this.convertBytes(totalBytes);
204
232
  percent = event.getPercent();
205
233
  FW.Log.debug(
206
- '正在更新中 -> ',
207
- '下载文件数量:',
234
+ "正在更新中 -> ",
235
+ "下载文件数量:",
208
236
  downloadedFiles,
209
- ',下载文件总数量:',
237
+ ",下载文件总数量:",
210
238
  totalFiles,
211
- ',已下载大小:',
239
+ ",已下载大小:",
212
240
  convertDownloadedBytes,
213
- ',下载总大小:',
241
+ ",下载总大小:",
214
242
  convertTotalBytes,
215
243
  );
216
244
  }
217
245
  break;
218
246
  case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST:
219
- str = 'ERROR_DOWNLOAD_MANIFEST';
247
+ str = "ERROR_DOWNLOAD_MANIFEST";
220
248
  break;
221
249
  case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST:
222
- str = 'ERROR_PARSE_MANIFEST';
250
+ str = "ERROR_PARSE_MANIFEST";
223
251
  failed = true;
224
252
  break;
225
253
  case jsb.EventAssetsManager.ALREADY_UP_TO_DATE:
226
- str = 'ALREADY_UP_TO_DATE';
254
+ str = "ALREADY_UP_TO_DATE";
227
255
  failed = true;
228
256
  break;
229
257
  case jsb.EventAssetsManager.UPDATE_FINISHED:
@@ -236,37 +264,37 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
236
264
  convertTotalBytes = this.convertBytes(totalBytes);
237
265
  percent = event.getPercent();
238
266
  FW.Log.debug(
239
- '正在更新完成 -> ',
240
- '下载文件数量:',
267
+ "正在更新完成 -> ",
268
+ "下载文件数量:",
241
269
  downloadedFiles,
242
- ',下载文件总数量:',
270
+ ",下载文件总数量:",
243
271
  totalFiles,
244
- ',已下载大小:',
272
+ ",已下载大小:",
245
273
  convertDownloadedBytes,
246
- ',下载总大小:',
274
+ ",下载总大小:",
247
275
  convertTotalBytes,
248
276
  );
249
277
  }
250
- str = 'UPDATE_FINISHED';
278
+ str = "UPDATE_FINISHED";
251
279
  needRestart = true;
252
280
  break;
253
281
  case jsb.EventAssetsManager.UPDATE_FAILED:
254
- str = 'UPDATE_FAILED';
282
+ str = "UPDATE_FAILED";
255
283
  this.isUpdate = false;
256
284
  this.isRetry = true;
257
285
  break;
258
286
  case jsb.EventAssetsManager.ERROR_UPDATING:
259
- str = 'ERROR_UPDATING';
287
+ str = "ERROR_UPDATING";
260
288
  break;
261
289
  case jsb.EventAssetsManager.ERROR_DECOMPRESS:
262
- str = 'ERROR_DECOMPRESS';
290
+ str = "ERROR_DECOMPRESS";
263
291
  break;
264
292
  default:
265
293
  break;
266
294
  }
267
295
 
268
- FW.Log.debug('热更新中->', str);
269
- FW.Log.debug('热更新msg ->', msg);
296
+ FW.Log.debug("热更新中->", str);
297
+ FW.Log.debug("热更新msg ->", msg);
270
298
  this.listener.hotUpdatingHandle?.(code, {
271
299
  percent: percent,
272
300
  downloadedFiles: downloadedFiles,
@@ -277,15 +305,15 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
277
305
  convertTotalBytes: convertTotalBytes,
278
306
  });
279
307
  if (failed) {
280
- FW.Log.debug('热更新中结果 failed -> ', failed);
281
- FW.Log.debug('下载失败');
308
+ FW.Log.debug("热更新中结果 failed -> ", failed);
309
+ FW.Log.debug("下载失败");
282
310
  this.assetMgr.setEventCallback(null!);
283
311
  this.isUpdate = false;
284
312
  this.retry();
285
313
  }
286
314
  if (needRestart) {
287
- FW.Log.debug('热更新中结果 needRestart -> ', needRestart);
288
- FW.Log.debug('下载完成');
315
+ FW.Log.debug("热更新中结果 needRestart -> ", needRestart);
316
+ FW.Log.debug("下载完成");
289
317
  const searchPaths = jsb.fileUtils.getSearchPaths();
290
318
  const newPaths = this.assetMgr.getLocalManifest().getSearchPaths();
291
319
  Array.prototype.unshift.apply(searchPaths, newPaths);
@@ -301,7 +329,7 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
301
329
  }
302
330
 
303
331
  private convertBytes(bytes: number) {
304
- const units = ['B', 'KB', 'MB', 'GB'];
332
+ const units = ["B", "KB", "MB", "GB"];
305
333
  let size = bytes,
306
334
  unitIndex = 0;
307
335
  while (size >= 1024 && unitIndex < units.length - 1) {
@@ -1,13 +1,10 @@
1
- import FWSocket from "../service/socket/FWSocket";
2
- import { FWManager } from "./FWManager";
1
+ import FWSocket from '../service/socket/FWSocket';
2
+ import { FWManager } from './FWManager';
3
3
 
4
4
  /**
5
5
  * socket管理器
6
6
  */
7
- export default class FWSocketManager
8
- extends FWManager
9
- implements FW.SocketManager
10
- {
7
+ export default class FWSocketManager extends FWManager implements FW.SocketManager {
11
8
  protected socketMap: Map<string, FW.Socket>;
12
9
 
13
10
  public initialize(): void {
@@ -71,7 +68,7 @@ export default class FWSocketManager
71
68
 
72
69
  closeAll(): void {
73
70
  for (const [key, socket] of this.socketMap) {
74
- socket?.close();
71
+ this.closeSocket(socket);
75
72
  }
76
73
  this.socketMap.clear();
77
74
  }
@@ -88,11 +85,9 @@ export default class FWSocketManager
88
85
  * @param fs
89
86
  * @returns
90
87
  */
91
- closeSocket(fs: FWSocket) {
92
- FW.Log.debug("主动关闭socket!");
93
- const tag = fs.getTag();
94
- fs.socket.close();
95
- fs.socket = null;
96
- this.socketMap.delete(tag);
88
+ closeSocket(fs: FW.Socket) {
89
+ FW.Log.debug('主动关闭socket!');
90
+ fs.close();
91
+ this.socketMap.delete(fs.getTag());
97
92
  }
98
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "2.3.6",
3
+ "version": "2.3.8",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": ["123456"],
@@ -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字符串映射方式做,后期优化
@@ -44,6 +44,8 @@ export default class FWSocket extends FW.Service implements FW.Socket {
44
44
  private protocolContainer: Map<Symbol, FW.ProtocolPolling>;
45
45
  /** 证书 */
46
46
  private certificate: cc.Asset;
47
+ /** 是否强制关闭 */
48
+ private forceClose: boolean;
47
49
 
48
50
  /**
49
51
  * 消息事件列表
@@ -70,7 +72,7 @@ export default class FWSocket extends FW.Service implements FW.Socket {
70
72
 
71
73
  this.tag = tag;
72
74
  this.address = address;
73
-
75
+ this.forceClose = false;
74
76
  this.clear();
75
77
 
76
78
  this.messageEvents = {};
@@ -109,14 +111,10 @@ export default class FWSocket extends FW.Service implements FW.Socket {
109
111
  this.heartInternal = config?.heartInternal || defaultConfig.heartInternal;
110
112
  this.heartTimeout = config?.heartTimeout || defaultConfig.heartTimeout;
111
113
  this.heartWeakTime = config?.heartWeakTime || defaultConfig.heartWeakTime;
112
- this.maxReconnectTimes =
113
- config?.maxReconnectTimes || defaultConfig.maxReconnectTimes;
114
- this.reconnectInternal =
115
- config?.reconnectInternal || defaultConfig.reconnectInternal;
116
- this.protocolSymbol =
117
- config?.protocolSymbol || defaultConfig.protocolSymbol;
118
- this.protocolPollingTime =
119
- config?.protocolPollingTime || defaultConfig.protocolPollingTime;
114
+ this.maxReconnectTimes = config?.maxReconnectTimes || defaultConfig.maxReconnectTimes;
115
+ this.reconnectInternal = config?.reconnectInternal || defaultConfig.reconnectInternal;
116
+ this.protocolSymbol = config?.protocolSymbol || defaultConfig.protocolSymbol;
117
+ this.protocolPollingTime = config?.protocolPollingTime || defaultConfig.protocolPollingTime;
120
118
 
121
119
  this.promiseProxy = {
122
120
  promise: undefined,
@@ -130,7 +128,7 @@ export default class FWSocket extends FW.Service implements FW.Socket {
130
128
 
131
129
  return this.promiseProxy;
132
130
  } catch (e) {
133
- FW.Log.error("创建socket失败:", e);
131
+ FW.Log.error('创建socket失败:', e);
134
132
  }
135
133
  }
136
134
  /**
@@ -172,8 +170,11 @@ export default class FWSocket extends FW.Service implements FW.Socket {
172
170
  */
173
171
  public close() {
174
172
  this.clear();
173
+ this.forceClose = true;
174
+ this.onSocketClose();
175
+ this.socket?.close();
176
+ this.socket = null;
175
177
  FW.Entry.timeMgr.unSchedule(this);
176
- FW.Entry.socketMgr.closeSocket(this);
177
178
  }
178
179
 
179
180
  public pauseMessageHandle() {
@@ -208,22 +209,16 @@ export default class FWSocket extends FW.Service implements FW.Socket {
208
209
  this.socket?.close();
209
210
  this.socket = null;
210
211
 
211
- this.createSocket(
212
- this.address,
213
- this.tag,
214
- this.socketSender,
215
- this.socketHandle,
216
- {
217
- heartInternal: this.heartInternal,
218
- heartTimeout: this.heartTimeout,
219
- heartWeakTime: this.heartWeakTime,
220
- maxReconnectTimes: this.maxReconnectTimes,
221
- reconnectInternal: this.reconnectInternal,
222
- protocolSymbol: this.protocolSymbol,
223
- protocolPollingTime: this.protocolPollingTime,
224
- certificate: this.certificate,
225
- },
226
- );
212
+ this.createSocket(this.address, this.tag, this.socketSender, this.socketHandle, {
213
+ heartInternal: this.heartInternal,
214
+ heartTimeout: this.heartTimeout,
215
+ heartWeakTime: this.heartWeakTime,
216
+ maxReconnectTimes: this.maxReconnectTimes,
217
+ reconnectInternal: this.reconnectInternal,
218
+ protocolSymbol: this.protocolSymbol,
219
+ protocolPollingTime: this.protocolPollingTime,
220
+ certificate: this.certificate,
221
+ });
227
222
  }
228
223
 
229
224
  async send(msg: string) {
@@ -233,8 +228,7 @@ export default class FWSocket extends FW.Service implements FW.Socket {
233
228
  const protocolKey = this.socketSender.getProtocolKey?.(msg);
234
229
  if (protocolKey) {
235
230
  const symbol = Symbol(protocolKey);
236
- const registry =
237
- this.protocolRegistry.get(protocolKey) || new Set<Symbol>();
231
+ const registry = this.protocolRegistry.get(protocolKey) || new Set<Symbol>();
238
232
  const protocolPolling: FW.ProtocolPolling = {
239
233
  msg: msg,
240
234
  schedule: FW.Entry.timeMgr.schedule(
@@ -255,7 +249,7 @@ export default class FWSocket extends FW.Service implements FW.Socket {
255
249
 
256
250
  /** 连接打开 */
257
251
  private onSocketOpen() {
258
- FW.Log.debug("on open!");
252
+ FW.Log.debug('on open!');
259
253
  FW.Entry.timeMgr.unSchedule(this);
260
254
  this.reconnectTimes = 0;
261
255
  this.sendHeartTimestamp = 0;
@@ -299,15 +293,19 @@ export default class FWSocket extends FW.Service implements FW.Socket {
299
293
 
300
294
  /** socket关闭 */
301
295
  private onSocketClose() {
302
- FW.Log.debug("on close!");
296
+ FW.Log.debug('on close!');
303
297
  this.socketHandle?.onClose?.();
298
+ this.socket.onclose = null;
299
+ this.socket.onerror = null;
300
+ this.socket.onmessage = null;
301
+ this.socket.onopen = null;
304
302
  FW.Entry.timeMgr.scheduleOnce(
305
303
  () => {
306
304
  if (
307
- this.getReadyState() == WebSocket.CLOSING ||
308
- this.getReadyState() == WebSocket.CLOSED
305
+ !this.forceClose &&
306
+ (this.getReadyState() == WebSocket.CLOSING || this.getReadyState() == WebSocket.CLOSED)
309
307
  ) {
310
- FW.Log.debug("on close!");
308
+ FW.Log.debug('on close!');
311
309
  this.reconnect();
312
310
  }
313
311
  },