cgserver 12.3.0 → 12.3.1

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/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # 版本更新日志
2
2
 
3
+ ## v12.3.1
4
+ - bugfix
5
+ - serverwebsocket支持wss
6
+
3
7
  ## v12.3.0
4
8
  - 中型版本更新
5
9
  - webserver websocketserver socketserver均取消默认数据库初始化,打算还是剥离
@@ -88,6 +88,7 @@ class RpcConfig {
88
88
  timeout = 0;
89
89
  host = "";
90
90
  port = -1;
91
+ wss = false;
91
92
  }
92
93
  exports.RpcConfig = RpcConfig;
93
94
  class CgMq {
@@ -134,7 +135,7 @@ class CgMq {
134
135
  this._ws = new CgMqServerWebsocket(this);
135
136
  }
136
137
  return new Promise(async (resolve, reject) => {
137
- this._ws.connect(cfg.host, cfg.port);
138
+ this._ws.connect(cfg.wss, cfg.host, cfg.port);
138
139
  let pretime = Date.now();
139
140
  while (true) {
140
141
  if (this._ws.connected) {
@@ -73,11 +73,16 @@ class IServerWebSocket extends IWebSocket_1.IWebSocket {
73
73
  get extraRequestOptions() {
74
74
  return this._extraRequestOptions;
75
75
  }
76
+ _wss = false;
77
+ get wss() {
78
+ return this._wss;
79
+ }
76
80
  _need_close = false;
77
81
  constructor(protoType = IProtoFilter_1.EProtoType.Json, protoPath = "") {
78
82
  super(protoType, protoPath);
79
83
  }
80
- connect(domain, port, requestedProtocols = null, origin = null, headers = null, extraRequestOptions = null) {
84
+ connect(wss, domain, port, requestedProtocols = null, origin = null, headers = null, extraRequestOptions = null) {
85
+ this._wss = wss;
81
86
  this._host = domain || this._host;
82
87
  this._port = port || this._port;
83
88
  this._requestedProtocols = requestedProtocols || this._requestedProtocols;
@@ -87,7 +92,7 @@ class IServerWebSocket extends IWebSocket_1.IWebSocket {
87
92
  this._connect();
88
93
  }
89
94
  _connect() {
90
- let url = "ws://" + this._host + ":" + this._port + "/";
95
+ let url = (this._wss ? "wss://" : "ws://") + this._host + ":" + this._port + "/";
91
96
  Log_1.gLog.info("Trying to connect to server : " + url);
92
97
  let _ws = new ws.client();
93
98
  _ws.on("connect", this.onConnect.bind(this));
@@ -31,6 +31,7 @@ export declare class RpcConfig {
31
31
  timeout: number;
32
32
  host: string;
33
33
  port: number;
34
+ wss: boolean;
34
35
  }
35
36
  export declare class CgMq {
36
37
  protected _ws: CgMqServerWebsocket;
@@ -25,9 +25,11 @@ export declare class IServerWebSocket extends IWebSocket {
25
25
  get headers(): http.OutgoingHttpHeaders;
26
26
  protected _extraRequestOptions: http.RequestOptions;
27
27
  get extraRequestOptions(): http.RequestOptions;
28
+ protected _wss: boolean;
29
+ get wss(): boolean;
28
30
  protected _need_close: boolean;
29
31
  constructor(protoType?: EProtoType, protoPath?: string);
30
- connect(domain: string, port: number, requestedProtocols?: string | string[], origin?: string, headers?: http.OutgoingHttpHeaders, extraRequestOptions?: http.RequestOptions): void;
32
+ connect(wss: boolean, domain: string, port: number, requestedProtocols?: string | string[], origin?: string, headers?: http.OutgoingHttpHeaders, extraRequestOptions?: http.RequestOptions): void;
31
33
  protected _connect(): void;
32
34
  onOpen(e?: any): void;
33
35
  onClose(reasonCode: number, description: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "12.3.0",
3
+ "version": "12.3.1",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",