cgserver 12.0.4 → 12.0.7
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 +217 -141
- package/dist/lib/Framework/Database/Mongo/MongoBaseService.js +4 -4
- package/dist/lib/Framework/Database/Mongo/MongoManager.js +6 -6
- package/dist/lib/Framework/Decorator/JsonAdminValidate.js +1 -1
- package/dist/lib/Framework/Server/RpcWebSocketServer/CgMq.js +2 -2
- package/dist/lib/Framework/Server/RpcWebSocketServer/IRpcClientWebSocket.js +3 -3
- package/dist/lib/Framework/Server/RpcWebSocketServer/IRpcServerWebSocket.js +1 -0
- package/dist/lib/Framework/Server/SocketServer/IServerSocket.js +16 -28
- package/dist/lib/Framework/Server/WebServer/Controller/MongoBaseUserController.js +1 -1
- package/dist/lib/Framework/Server/WebServer/Controller/MysqlBaseUserController.js +1 -1
- package/dist/lib/Framework/Server/WebSocketServer/IWebSocketServer.js +1 -1
- package/dist/lib/Framework/Service/MongoCacheService.js +1 -1
- package/dist/lib/Framework/Service/MongoUserService.js +1 -0
- package/dist/types/Framework/Database/Mongo/MongoBaseService.d.ts +2 -2
- package/dist/types/Framework/Database/Mongo/MongoManager.d.ts +2 -2
- package/dist/types/Framework/Server/SocketServer/IServerSocket.d.ts +1 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,141 +1,217 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
2
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
1
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
2
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
1
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
1
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
1
|
|
88
|
-
9.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
1
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
1
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
1
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
1
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
1
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
1
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
1
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
3
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
1
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
1
|
+
# 版本更新日志
|
|
2
|
+
|
|
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
|
|
@@ -66,12 +66,12 @@ class MongoBaseService {
|
|
|
66
66
|
let rs = await this.mongoDb.simpleAggregate(this._table, where, property, null, num);
|
|
67
67
|
return rs.list;
|
|
68
68
|
}
|
|
69
|
-
async updateOne(where, model,
|
|
70
|
-
let rs = await this.mongoDb.updateOne(this._table, where, model,
|
|
69
|
+
async updateOne(where, model, options) {
|
|
70
|
+
let rs = await this.mongoDb.updateOne(this._table, where, model, options);
|
|
71
71
|
return rs;
|
|
72
72
|
}
|
|
73
|
-
async updateMany(where, model = null,
|
|
74
|
-
let rs = await this.mongoDb.updateMany(this._table, where, model,
|
|
73
|
+
async updateMany(where, model = null, options) {
|
|
74
|
+
let rs = await this.mongoDb.updateMany(this._table, where, model, options);
|
|
75
75
|
return rs;
|
|
76
76
|
}
|
|
77
77
|
async insert(model) {
|
|
@@ -374,7 +374,7 @@ class MongoExt {
|
|
|
374
374
|
rs.rs = in_rs;
|
|
375
375
|
return rs;
|
|
376
376
|
}
|
|
377
|
-
async updateOne(collection, where, model,
|
|
377
|
+
async updateOne(collection, where, model, options) {
|
|
378
378
|
let _id = model["_id"];
|
|
379
379
|
delete model["_id"];
|
|
380
380
|
if (!where && _id) {
|
|
@@ -405,10 +405,10 @@ class MongoExt {
|
|
|
405
405
|
updatemodel = model;
|
|
406
406
|
}
|
|
407
407
|
let col = this._mongoDb.collection(collection);
|
|
408
|
-
up_rs = await col.updateOne(where, updatemodel,
|
|
408
|
+
up_rs = await col.updateOne(where, updatemodel, options);
|
|
409
409
|
}
|
|
410
410
|
catch (e) {
|
|
411
|
-
Log_1.gLog.error({ collection, model, where,
|
|
411
|
+
Log_1.gLog.error({ collection, model, where, options });
|
|
412
412
|
Log_1.gLog.error(e.stack);
|
|
413
413
|
rs.errcode = _error_1.EErrorCode.Mongo_Error;
|
|
414
414
|
}
|
|
@@ -418,7 +418,7 @@ class MongoExt {
|
|
|
418
418
|
}
|
|
419
419
|
return rs;
|
|
420
420
|
}
|
|
421
|
-
async updateMany(collection, where, model,
|
|
421
|
+
async updateMany(collection, where, model, options) {
|
|
422
422
|
this._convertWhere(where);
|
|
423
423
|
let rs = { errcode: null, rs: null };
|
|
424
424
|
if (!this._mongoDb) {
|
|
@@ -436,10 +436,10 @@ class MongoExt {
|
|
|
436
436
|
updateModel = model;
|
|
437
437
|
}
|
|
438
438
|
let col = this._mongoDb.collection(collection);
|
|
439
|
-
up_rs = await col.updateMany(where, updateModel,
|
|
439
|
+
up_rs = await col.updateMany(where, updateModel, options);
|
|
440
440
|
}
|
|
441
441
|
catch (e) {
|
|
442
|
-
Log_1.gLog.error({ collection, model, where,
|
|
442
|
+
Log_1.gLog.error({ collection, model, where, options });
|
|
443
443
|
Log_1.gLog.error(e.stack);
|
|
444
444
|
rs.errcode = _error_1.EErrorCode.Mongo_Error;
|
|
445
445
|
}
|
|
@@ -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: "需要管理员或创始人权限" }
|
|
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 >=
|
|
145
|
+
if (now - pretime >= this._cfg.timeout) {
|
|
146
146
|
this._ws.close();
|
|
147
147
|
resolve(false);
|
|
148
148
|
break;
|
|
@@ -156,7 +156,7 @@ class IRpcClientWebSocket extends IClientWebSocket_1.IClientWebSocket {
|
|
|
156
156
|
super(server);
|
|
157
157
|
this._debug_msg = true;
|
|
158
158
|
this._group = "";
|
|
159
|
-
this._id =
|
|
159
|
+
this._id = Core_1.core.getUuid();
|
|
160
160
|
}
|
|
161
161
|
getWsByGroup(group, listen) {
|
|
162
162
|
let wses = [];
|
|
@@ -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
|
-
|
|
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,30 @@ 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
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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", this.onConnect.bind(this));
|
|
47
|
+
this._socket.on("error", this.onError.bind(this));
|
|
48
|
+
this._socket.on("close", this.onClose.bind(this));
|
|
49
|
+
this._socket.on("data", this._onData.bind(this));
|
|
50
|
+
this.onOpen();
|
|
63
51
|
}
|
|
64
52
|
onOpen(e) {
|
|
65
53
|
super.onOpen(e);
|
|
@@ -140,7 +140,7 @@ class MongoBaseUserController extends BaseController_1.BaseController {
|
|
|
140
140
|
cm.key = this._session_id;
|
|
141
141
|
cm.data = user.id;
|
|
142
142
|
cm.expireAt = Date.now() + time * 1000;
|
|
143
|
-
MongoCacheService_1.gMongoCacheSer.updateOne({ key: cm.key }, cm, true);
|
|
143
|
+
MongoCacheService_1.gMongoCacheSer.updateOne({ key: cm.key }, cm, { upsert: true });
|
|
144
144
|
}
|
|
145
145
|
this._self_user = user;
|
|
146
146
|
}
|
|
@@ -138,7 +138,7 @@ class MysqlBaseUserController extends BaseController_1.BaseController {
|
|
|
138
138
|
cm.key = this._session_id;
|
|
139
139
|
cm.data = user.id;
|
|
140
140
|
cm.expireAt = Date.now() + time * 1000;
|
|
141
|
-
MongoCacheService_1.gMongoCacheSer.updateOne({ key: cm.key }, cm, true);
|
|
141
|
+
MongoCacheService_1.gMongoCacheSer.updateOne({ key: cm.key }, cm, { upsert: true });
|
|
142
142
|
}
|
|
143
143
|
this._self_user = user;
|
|
144
144
|
}
|
|
@@ -164,7 +164,7 @@ class IWebSocketServer {
|
|
|
164
164
|
this.createWebSocketObjectByProtocol(server_name, conn, req);
|
|
165
165
|
}
|
|
166
166
|
catch (e) {
|
|
167
|
-
Log_1.gLog.error(
|
|
167
|
+
Log_1.gLog.error(e);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
createWebSocketObjectByProtocol(server_name, _ws, req) {
|
|
@@ -39,7 +39,7 @@ class MongoCacheService extends MongoBaseService_1.MongoBaseService {
|
|
|
39
39
|
mcm.key = key;
|
|
40
40
|
mcm.data = data;
|
|
41
41
|
mcm.expireAt = expireAt;
|
|
42
|
-
let rs = await this.updateOne({ key: mcm.key }, mcm, true);
|
|
42
|
+
let rs = await this.updateOne({ key: mcm.key }, mcm, { upsert: true });
|
|
43
43
|
if (rs.rs.upsertedCount <= 0) {
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
@@ -40,7 +40,7 @@ export declare class MongoBaseService<T extends MongoBaseModel> {
|
|
|
40
40
|
}): Promise<T[]>;
|
|
41
41
|
updateOne(where: {
|
|
42
42
|
[key: string]: any;
|
|
43
|
-
}, model: any,
|
|
43
|
+
}, model: any, options?: mongo.UpdateOptions): Promise<{
|
|
44
44
|
errcode: {
|
|
45
45
|
id: number;
|
|
46
46
|
des: string;
|
|
@@ -49,7 +49,7 @@ export declare class MongoBaseService<T extends MongoBaseModel> {
|
|
|
49
49
|
}>;
|
|
50
50
|
updateMany(where: {
|
|
51
51
|
[key: string]: any;
|
|
52
|
-
}, model?: any,
|
|
52
|
+
}, model?: any, options?: mongo.UpdateOptions): Promise<{
|
|
53
53
|
errcode: {
|
|
54
54
|
id: number;
|
|
55
55
|
des: string;
|
|
@@ -158,7 +158,7 @@ export declare class MongoExt {
|
|
|
158
158
|
}>;
|
|
159
159
|
updateOne(collection: string, where: {
|
|
160
160
|
[key: string]: any;
|
|
161
|
-
}, model: any,
|
|
161
|
+
}, model: any, options?: mongo.UpdateOptions): Promise<{
|
|
162
162
|
errcode: {
|
|
163
163
|
id: number;
|
|
164
164
|
des: string;
|
|
@@ -167,7 +167,7 @@ export declare class MongoExt {
|
|
|
167
167
|
}>;
|
|
168
168
|
updateMany(collection: string, where: {
|
|
169
169
|
[key: string]: any;
|
|
170
|
-
}, model: any,
|
|
170
|
+
}, model: any, options?: mongo.UpdateOptions): Promise<{
|
|
171
171
|
errcode: {
|
|
172
172
|
id: number;
|
|
173
173
|
des: string;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
3
|
import { ISocket } from './ISocket';
|
|
5
4
|
import { EProtoType } from '../ProtoFilter/IProtoFilter';
|
|
6
|
-
import * as http from "http";
|
|
7
5
|
/**
|
|
8
6
|
* 连接到服务器的websocket
|
|
9
7
|
* 默认自动重连
|
|
@@ -19,17 +17,9 @@ export declare class IServerSocket extends ISocket {
|
|
|
19
17
|
* 连接的服务器端口
|
|
20
18
|
*/
|
|
21
19
|
get port(): number;
|
|
22
|
-
protected _requestedProtocols: string | string[];
|
|
23
|
-
get requestedProtocols(): string | string[];
|
|
24
|
-
protected _origin: string;
|
|
25
|
-
get origin(): string;
|
|
26
|
-
protected _headers: http.OutgoingHttpHeaders;
|
|
27
|
-
get headers(): http.OutgoingHttpHeaders;
|
|
28
|
-
protected _extraRequestOptions: http.RequestOptions;
|
|
29
|
-
get extraRequestOptions(): http.RequestOptions;
|
|
30
20
|
protected _need_close: boolean;
|
|
31
21
|
constructor(protoType?: EProtoType, protoPath?: string);
|
|
32
|
-
connect(domain: string, port: number
|
|
22
|
+
connect(domain: string, port: number): void;
|
|
33
23
|
protected _connect(): void;
|
|
34
24
|
onOpen(e?: any): void;
|
|
35
25
|
onClose(reasonCode: number, description: string): boolean;
|