@ives_xxz/framework 1.2.22 → 1.3.0

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
@@ -281,6 +281,7 @@ declare namespace FW {
281
281
  reconnectInternal: number;
282
282
  protocolSymbol: Symbol;
283
283
  protocolPollingTime: number;
284
+ certificate: cc.Asset;
284
285
  };
285
286
 
286
287
  /**
@@ -1490,7 +1491,7 @@ declare namespace FW {
1490
1491
  /**
1491
1492
  * 状态构造类
1492
1493
  */
1493
- stateConstructor: { new (): T };
1494
+ stateConstructor: { new(): T };
1494
1495
  };
1495
1496
 
1496
1497
  type AudioManager = {
@@ -36,6 +36,8 @@ export default class FWSocketManager extends FWManager implements FW.SocketManag
36
36
  maxReconnectTimes: config.maxReconnectTimes,
37
37
  reconnectInternal: config.reconnectInternal,
38
38
  protocolSymbol: config.protocolSymbol,
39
+ protocolPollingTime: config.protocolPollingTime,
40
+ certificate: config.certificate,
39
41
  });
40
42
  this.socketMap.set(tag, proxy.socket);
41
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "1.2.22",
3
+ "version": "1.3.0",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -45,6 +45,8 @@ export default class FWSocket implements FW.Socket {
45
45
  private protocolRegistry: Map<string, Set<Symbol>>;
46
46
  /** 协议符号容器 */
47
47
  private protocolContainer: Map<Symbol, FW.ProtocolPolling>;
48
+ /** 证书 */
49
+ private certificate: cc.Asset;
48
50
 
49
51
  /**
50
52
  * 消息事件列表
@@ -82,7 +84,26 @@ export default class FWSocket implements FW.Socket {
82
84
  this.sendHeartTimestamp = 0;
83
85
  this.receiveTimeStamp = new Date().getTime();
84
86
 
85
- this.socket = new WebSocket(address);
87
+ if (cc.sys.isBrowser) {
88
+ this.socket = new WebSocket(address);
89
+ } else {
90
+ if (config.certificate) {
91
+ let url = config.certificate.nativeUrl;
92
+ if (cc.assetManager.cacheManager) {
93
+ url =
94
+ cc.assetManager.cacheManager.getCache(url) ||
95
+ cc.assetManager.cacheManager.getTemp(url) ||
96
+ url;
97
+ }
98
+ //@ts-ignore
99
+ this.socket = new WebSocket(address, [], url);
100
+ } else {
101
+ this.socket = new WebSocket(address);
102
+ }
103
+ }
104
+
105
+
106
+
86
107
  this.socket.onopen = this.onSocketOpen.bind(this);
87
108
  this.socket.onclose = this.onSocketClose.bind(this);
88
109
  this.socket.onerror = this.onSocketError.bind(this);
@@ -196,6 +217,7 @@ export default class FWSocket implements FW.Socket {
196
217
  reconnectInternal: this.reconnectInternal,
197
218
  protocolSymbol: this.protocolSymbol,
198
219
  protocolPollingTime: this.protocolPollingTime,
220
+ certificate: this.certificate,
199
221
  });
200
222
  }
201
223