cgserver 12.0.5 → 12.0.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.
package/README.md CHANGED
@@ -1,144 +1,217 @@
1
+ # 版本更新日志
1
2
 
2
- 12.0.6
3
- 1、修复IRpcClientWebSocket初始化bug
4
- 12.0.0
5
- 1、增加socketserver
6
- 11.2.5
7
- 1、Engine 增加app接口
8
- 11.2.2
9
- 1、日志默认log
10
- 11.2.1
11
- 1、日志新配置
12
- 2、新rpc
13
- 10.2.1
14
- 1、cgrank支持密码
15
- 10.2.0
16
- 1、修复redis
17
- 2、增加对cgrank的支持
18
- 10.0.25
19
- 1、Config 支持原始数据
20
- 10.0.23
21
- 1、日志默认log_file
22
- 2、添加minimist解析参数
23
- 10.0.20
24
- 1、增加bulkwrite接口
25
- 10.0.9
26
- 1、修复mongoservicemanager的接口bug
27
- 10.0.8
28
- 1、精简mongoservicemanager的接口
29
- 10.0.7
30
- 1、细微修改mongoservicemanager
31
- 10.0.1-10.0.7
32
- 1、一些列优化和bug修正
33
- 10.0.0
34
- 1、老项目切忌不要轻易升级
35
- 2、老项目切忌不要轻易升级
36
- 3、老项目切忌不要轻易升级
37
-
38
- 1、修改引入方式
39
- 2、修改mongo的where和property顺序
40
-
41
- 9.2.7
42
- 1、主要针对配置政策修改
43
- 9.2.1
44
- 1、增强提示
45
- 9.2.0
46
- 1、mysql 更换为mysql2
47
- 9.1.23
48
- 1、日志系统整理
49
- 9.1.22
50
- 1、日志系统整理
51
- 9.1.21
52
- 1、express 全局异常捕获日志
53
- 9.1.20
54
- 1、没什么就是一个日志配置功能功能
55
- 9.1.19
56
- 1、尴尬修改的是9.18的问题
57
- 9.1.18
58
- 1、普通日志默认100个文件
59
- 9.1.17
60
- 1、IServerWebSocket的重连可能的bug
61
- 9.1.16
62
- 1、websocket客户端无需强制配置服务器配置文件,debug_msg
63
- 9.1.15
64
- 1、websocket请求连接端扩展
65
- 9.1.14
66
- 1、http请求、websocker处理时间、rpc请求处理时间
67
- 9.1.13
68
- 1、请求的时间消耗提示优化
69
- 9.1.12
70
- 1、部分httpserver 请求bug修改
71
- 9.1.11
72
- 1、部分httpserver的代码整理
73
- 9.1.10
74
- 1、删除一些无用配置和代码
75
- 2、整理现有的代码,增加一些人性化的提示
76
- 9.1.9
77
- 1、周起始时间bug修正
78
- 9.1.8
79
- 1、强制mongocache访问mongo的bug修改
80
- 9.1.7
81
- 1、httptool 默认可以支持全局输出日志了
82
- 9.1.6
83
- 1、默认不适用losslessjson,会把数字变成对象
84
- 9.1.5
85
- 1、https只单独监听
86
- 9.1.3
87
- 1、几乎同意替换成losslessjson
88
- 2、express使用了raw
89
- 9.1.2
90
- 1、losslessjson
91
- 9.1.1
92
- 1、扩展mongomgr的一个接口addMongo,removeMongo方便自由增减
93
- 2、清除部分无用代码
94
- 3、mongoext的mongoclient未被初始化修正
95
- 9.1.0
96
- 1、支持多mongo示例
97
- 2、支持多service实例
98
- ps:新的service必须是无参数得constructor
99
- 9.0.7(重要修复)
100
- 1、修复createFilter的bug
101
- 9.0.6(修复bug)
102
- 1、IRpcClientWebSocket toRetMsg的bug修正
103
- 9.0.5(不重要)
104
- 1、添加一个rpc提示
105
- 9.0.4
106
- 1、rpc回复指定发送的消息的位置不正确的bug
107
- 9.0.3
108
- 1、request添加rawBody接口,方便获取原始body字符串
109
- 2、v4替换uuidv4(官方弃用,现有接口不影响)
110
- 3、增强rpc的提示
111
- 9.0.2
112
- 1、修复uuid问题
113
- 9.0.0
114
- 1、升级了新的rpc,支持分组和具体
115
- 2、rpc至少请使用2.0.0版本
116
- 8.9.18
117
- 1、支持自定义进程id
118
- 8.9.17
119
- 1、支持websocketserver 暂停和恢复
120
- 2、支持webserver 暂停和恢复
121
- 8.9.16
122
- 1、ws暴露当时请求的req
123
- 8.9.15
124
- 1、暴露mongo的objectid
125
- 8.9.14
126
- 1、字节操作能力
127
- 8.9.13
128
- 1、protofilter 可扩展
129
- 8.9.6
130
- 1、webview的view可配置
131
- 8.9.4
132
- 1、扩展签名和验签功能
133
- 8.6.9
134
- 1、update all packages
135
- 2、remove webpack about packages
136
- 3、remove file request,instead,use express static config
137
- 8.6.7
138
- 1、getAutoIds bug修改
139
- 8.6.6
140
- 1、SyncCall2 this丢失的bug修正
141
- 8.6.2
142
- 1、C# post url-encoded data support
143
- 8.6.1
144
- 1、quickTrasaction support options
3
+ ## v12.0.7
4
+ - 修复IServerSocket
5
+
6
+ ### v12.0.6
7
+ - 修复IRpcClientWebSocket初始化bug
8
+
9
+ ### v12.0.0
10
+ - 增加socketserver
11
+
12
+ ## v11.x
13
+
14
+ ### v11.2.5
15
+ - Engine 增加app接口
16
+
17
+ ### v11.2.2
18
+ - 日志默认log
19
+
20
+ ### v11.2.1
21
+ - 日志新配置
22
+ - 新rpc
23
+
24
+ ## v10.x
25
+
26
+ ### v10.2.1
27
+ - cgrank支持密码
28
+
29
+ ### v10.2.0
30
+ - 修复redis
31
+ - 增加对cgrank的支持
32
+
33
+ ### v10.0.25
34
+ - Config 支持原始数据
35
+
36
+ ### v10.0.23
37
+ - 日志默认log_file
38
+ - 添加minimist解析参数
39
+
40
+ ### v10.0.20
41
+ - 增加bulkwrite接口
42
+
43
+ ### v10.0.9
44
+ - 修复mongoservicemanager的接口bug
45
+
46
+ ### v10.0.8
47
+ - 精简mongoservicemanager的接口
48
+
49
+ ### v10.0.7
50
+ - 细微修改mongoservicemanager
51
+
52
+ ### v10.0.1-10.0.7
53
+ - 一些列优化和bug修正
54
+
55
+ ### v10.0.0
56
+ > **警告**:
57
+ > - 老项目切忌不要轻易升级
58
+ > - 老项目切忌不要轻易升级
59
+ > - 老项目切忌不要轻易升级
60
+
61
+ - 修改引入方式
62
+ - 修改mongo的where和property顺序
63
+
64
+ ## v9.x
65
+
66
+ ### v9.2.7
67
+ - 主要针对配置政策修改
68
+
69
+ ### v9.2.1
70
+ - 增强提示
71
+
72
+ ### v9.2.0
73
+ - mysql 更换为mysql2
74
+
75
+ ### v9.1.23
76
+ - 日志系统整理
77
+
78
+ ### v9.1.22
79
+ - 日志系统整理
80
+
81
+ ### v9.1.21
82
+ - express 全局异常捕获日志
83
+
84
+ ### v9.1.20
85
+ - 没什么就是一个日志配置功能功能
86
+
87
+ ### v9.1.19
88
+ - 尴尬修改的是9.18的问题
89
+
90
+ ### v9.1.18
91
+ - 普通日志默认100个文件
92
+
93
+ ### v9.1.17
94
+ - IServerWebSocket的重连可能的bug
95
+
96
+ ### v9.1.16
97
+ - websocket客户端无需强制配置服务器配置文件,debug_msg
98
+
99
+ ### v9.1.15
100
+ - websocket请求连接端扩展
101
+
102
+ ### v9.1.14
103
+ - http请求、websocker处理时间、rpc请求处理时间
104
+
105
+ ### v9.1.13
106
+ - 请求的时间消耗提示优化
107
+
108
+ ### v9.1.12
109
+ - 部分httpserver 请求bug修改
110
+
111
+ ### v9.1.11
112
+ - 部分httpserver的代码整理
113
+
114
+ ### v9.1.10
115
+ - 删除一些无用配置和代码
116
+ - 整理现有的代码,增加一些人性化的提示
117
+
118
+ ### v9.1.9
119
+ - 周起始时间bug修正
120
+
121
+ ### v9.1.8
122
+ - 强制mongocache访问mongo的bug修改
123
+
124
+ ### v9.1.7
125
+ - httptool 默认可以支持全局输出日志了
126
+
127
+ ### v9.1.6
128
+ - 默认不适用losslessjson,会把数字变成对象
129
+
130
+ ### v9.1.5
131
+ - https只单独监听
132
+
133
+ ### v9.1.3
134
+ - 几乎同意替换成losslessjson
135
+ - express使用了raw
136
+
137
+ ### v9.1.2
138
+ - losslessjson
139
+
140
+ ### v9.1.1
141
+ - 扩展mongomgr的一个接口addMongo,removeMongo方便自由增减
142
+ - 清除部分无用代码
143
+ - mongoext的mongoclient未被初始化修正
144
+
145
+ ### v9.1.0
146
+ - 支持多mongo示例
147
+ - 支持多service实例
148
+
149
+ > 注:新的service必须是无参数得constructor
150
+
151
+ ### v9.0.7 (重要修复)
152
+ - 修复createFilter的bug
153
+
154
+ ### v9.0.6 (修复bug)
155
+ - IRpcClientWebSocket toRetMsg的bug修正
156
+
157
+ ### v9.0.5 (不重要)
158
+ - 添加一个rpc提示
159
+
160
+ ### v9.0.4
161
+ - rpc回复指定发送的消息的位置不正确的bug
162
+
163
+ ### v9.0.3
164
+ - request添加rawBody接口,方便获取原始body字符串
165
+ - v4替换uuidv4(官方弃用,现有接口不影响)
166
+ - 增强rpc的提示
167
+
168
+ ### v9.0.2
169
+ - 修复uuid问题
170
+
171
+ ### v9.0.0
172
+ - 升级了新的rpc,支持分组和具体
173
+ - rpc至少请使用2.0.0版本
174
+
175
+ ## v8.x
176
+
177
+ ### v8.9.18
178
+ - 支持自定义进程id
179
+
180
+ ### v8.9.17
181
+ - 支持websocketserver 暂停和恢复
182
+ - 支持webserver 暂停和恢复
183
+
184
+ ### v8.9.16
185
+ - ws暴露当时请求的req
186
+
187
+ ### v8.9.15
188
+ - 暴露mongo的objectid
189
+
190
+ ### v8.9.14
191
+ - 字节操作能力
192
+
193
+ ### v8.9.13
194
+ - protofilter 可扩展
195
+
196
+ ### v8.9.6
197
+ - webview的view可配置
198
+
199
+ ### v8.9.4
200
+ - 扩展签名和验签功能
201
+
202
+ ### v8.6.9
203
+ - update all packages
204
+ - remove webpack about packages
205
+ - remove file request,instead,use express static config
206
+
207
+ ### v8.6.7
208
+ - getAutoIds bug修改
209
+
210
+ ### v8.6.6
211
+ - SyncCall2 this丢失的bug修正
212
+
213
+ ### v8.6.2
214
+ - C# post url-encoded data support
215
+
216
+ ### v8.6.1
217
+ - quickTrasaction support options
@@ -6,7 +6,7 @@ function JsonAdminValidate(target, propertyName, descriptor) {
6
6
  descriptor.value = function () {
7
7
  let self = this;
8
8
  if (!self.isAdmin) {
9
- self.showJson({ errcode: { id: 1, des: "需要管理员或创始人权限" }, err: "需要管理员或创始人权限" });
9
+ self.showJson({ errcode: { id: 1, des: "需要管理员或创始人权限" } });
10
10
  return;
11
11
  }
12
12
  return method.apply(this, arguments);
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CgMq = exports.RpcConfig = void 0;
4
4
  const Core_1 = require("../../Core/Core");
5
- const Log_1 = require("../../Logic/Log");
6
5
  const IRpcServerWebSocket_1 = require("./IRpcServerWebSocket");
6
+ const Log_1 = require("../../Logic/Log");
7
7
  class CgMqServerWebsocket extends IRpcServerWebSocket_1.IRpcServerWebSocket {
8
8
  _cgmq = null;
9
9
  _listens = {};
@@ -142,7 +142,7 @@ class CgMq {
142
142
  break;
143
143
  }
144
144
  let now = Date.now();
145
- if (now - pretime >= 3 * 1000) {
145
+ if (now - pretime >= this._cfg.timeout) {
146
146
  this._ws.close();
147
147
  resolve(false);
148
148
  break;
@@ -187,8 +187,7 @@ class IRpcClientWebSocket extends IClientWebSocket_1.IClientWebSocket {
187
187
  }
188
188
  async receive_msg(req_msg) {
189
189
  if (!req_msg.__rpcid) {
190
- let retMsg = this.getNewMsg("msg", { id: 10001, des: "非法rpc消息" });
191
- this.send(retMsg);
190
+ //直接丢掉
192
191
  return;
193
192
  }
194
193
  if (!req_msg.to_group) {
@@ -207,6 +206,7 @@ class IRpcClientWebSocket extends IClientWebSocket_1.IClientWebSocket {
207
206
  //发送给远程服务器的消息
208
207
  if (wses.length == 0) {
209
208
  req_msg.errcode = { id: 10004, des: "一个接收者都没找到" };
209
+ req_msg.__return = true;
210
210
  this.send(req_msg);
211
211
  return;
212
212
  }
@@ -69,6 +69,7 @@ class IRpcServerWebSocket extends IServerWebSocket_1.IServerWebSocket {
69
69
  handler = setTimeout(() => {
70
70
  EventTool_1.gEventTool.off(msg.__rpcid, func);
71
71
  let error_msg = this.getNewMsg(msg.cmd, { id: 10086, des: "timeout" });
72
+ error_msg.__return = true;
72
73
  resolve(error_msg);
73
74
  }, this._timeout);
74
75
  EventTool_1.gEventTool.once(msg.__rpcid, func);
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IServerSocket = void 0;
4
4
  const ISocket_1 = require("./ISocket");
5
- const ws = require("websocket");
6
5
  const IProtoFilter_1 = require("../ProtoFilter/IProtoFilter");
7
6
  const Log_1 = require("../../Logic/Log");
7
+ const net = require("net");
8
8
  /**
9
9
  * 连接到服务器的websocket
10
10
  * 默认自动重连
@@ -24,42 +24,28 @@ class IServerSocket extends ISocket_1.ISocket {
24
24
  get port() {
25
25
  return this._port;
26
26
  }
27
- _requestedProtocols = null;
28
- get requestedProtocols() {
29
- return this._requestedProtocols;
30
- }
31
- _origin = null;
32
- get origin() {
33
- return this._origin;
34
- }
35
- _headers = null;
36
- get headers() {
37
- return this._headers;
38
- }
39
- _extraRequestOptions = null;
40
- get extraRequestOptions() {
41
- return this._extraRequestOptions;
42
- }
43
27
  _need_close = false;
44
28
  constructor(protoType = IProtoFilter_1.EProtoType.Json, protoPath = "") {
45
29
  super(protoType, protoPath);
46
30
  }
47
- connect(domain, port, requestedProtocols = null, origin = null, headers = null, extraRequestOptions = null) {
31
+ connect(domain, port) {
48
32
  this._host = domain || this._host;
49
33
  this._port = port || this._port;
50
- this._requestedProtocols = requestedProtocols || this._requestedProtocols;
51
- this._origin = origin || this._origin;
52
- this._headers = headers || this._headers;
53
- this._extraRequestOptions = extraRequestOptions || this._extraRequestOptions;
54
34
  this._connect();
55
35
  }
56
36
  _connect() {
57
- let url = "ws://" + this._host + ":" + this._port + "/";
58
- Log_1.gLog.info("Trying to connect to server : " + url);
59
- let _ws = new ws.client();
60
- _ws.on("connect", this.onConnect.bind(this));
61
- _ws.on("connectFailed", this.onClose.bind(this));
62
- _ws.connect(url, this._requestedProtocols, this._origin, this._headers, this._extraRequestOptions);
37
+ if (this._socket) {
38
+ this._socket.destroy();
39
+ this._socket = null;
40
+ }
41
+ this._need_close = false;
42
+ let url = `${this._host}:${this._port}`;
43
+ Log_1.gLog.info(this._socket_id + ":try to connect to " + url);
44
+ this._socket = new net.Socket();
45
+ this._socket.connect(this._port, this._host);
46
+ this._socket.on("connect", () => {
47
+ this.onConnect(this._socket);
48
+ });
63
49
  }
64
50
  onOpen(e) {
65
51
  super.onOpen(e);
@@ -51,6 +51,7 @@ class MongoUserService extends MongoBaseService_1.MongoBaseService {
51
51
  um.state = 0;
52
52
  um.role_group = group;
53
53
  um.role = 0;
54
+ um.create_time = Date.now();
54
55
  //随机userid
55
56
  let id = 0;
56
57
  do {
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { ISocketServer } from './ISocketServer';
3
4
  import { ISocket } from './ISocket';
4
5
  import { EProtoType } from '../ProtoFilter/IProtoFilter';
@@ -2,7 +2,6 @@
2
2
  /// <reference types="node" />
3
3
  import { ISocket } from './ISocket';
4
4
  import { EProtoType } from '../ProtoFilter/IProtoFilter';
5
- import * as http from "http";
6
5
  /**
7
6
  * 连接到服务器的websocket
8
7
  * 默认自动重连
@@ -18,17 +17,9 @@ export declare class IServerSocket extends ISocket {
18
17
  * 连接的服务器端口
19
18
  */
20
19
  get port(): number;
21
- protected _requestedProtocols: string | string[];
22
- get requestedProtocols(): string | string[];
23
- protected _origin: string;
24
- get origin(): string;
25
- protected _headers: http.OutgoingHttpHeaders;
26
- get headers(): http.OutgoingHttpHeaders;
27
- protected _extraRequestOptions: http.RequestOptions;
28
- get extraRequestOptions(): http.RequestOptions;
29
20
  protected _need_close: boolean;
30
21
  constructor(protoType?: EProtoType, protoPath?: string);
31
- connect(domain: string, port: number, requestedProtocols?: string | string[], origin?: string, headers?: http.OutgoingHttpHeaders, extraRequestOptions?: http.RequestOptions): void;
22
+ connect(domain: string, port: number): void;
32
23
  protected _connect(): void;
33
24
  onOpen(e?: any): void;
34
25
  onClose(reasonCode: number, description: string): boolean;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
+ /// <reference types="node" />
3
4
  import { IProtoFilter, EProtoType } from "../ProtoFilter/IProtoFilter";
4
5
  import * as net from "net";
5
6
  import { PacketParser } from "./PacketParser";
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  export declare class PacketParser {
3
4
  protected buffer: Buffer;
4
5
  protected offset: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "12.0.5",
3
+ "version": "12.0.8",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",