cgserver 8.9.18 → 9.0.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/README.md +3 -0
- package/dist/lib/Framework/Config/FrameworkConfig.js +1 -1
- package/dist/lib/Framework/Core/Core.js +4 -0
- package/dist/lib/Framework/SocketServer/IRpc.js +23 -3
- package/dist/lib/Framework/SocketServer/IRpcClientWebSocket.js +19 -9
- package/dist/lib/Framework/SocketServer/IRpcServerWebSocket.js +28 -14
- package/dist/lib/Framework/ThirdParty/CgMq.js +45 -48
- package/dist/lib/Framework/ThirdParty/Rpc.js +13 -16
- package/dist/lib/Framework/index.js +4 -5
- package/dist/types/Framework/Config/FrameworkConfig.d.ts +2 -2
- package/dist/types/Framework/Core/Core.d.ts +1 -0
- package/dist/types/Framework/SocketServer/IRpc.d.ts +22 -2
- package/dist/types/Framework/SocketServer/IRpcClientWebSocket.d.ts +13 -7
- package/dist/types/Framework/SocketServer/IRpcServerWebSocket.d.ts +14 -7
- package/dist/types/Framework/ThirdParty/CgMq.d.ts +29 -35
- package/dist/types/Framework/ThirdParty/Rpc.d.ts +9 -9
- package/dist/types/Framework/index.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -677,5 +677,9 @@ class core {
|
|
|
677
677
|
let verificationResult = key.createVerify(rsa_name).update(payload).verify(signature, 'base64');
|
|
678
678
|
return verificationResult;
|
|
679
679
|
}
|
|
680
|
+
static async delay(milliseconds) {
|
|
681
|
+
let pm = new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
682
|
+
return pm;
|
|
683
|
+
}
|
|
680
684
|
}
|
|
681
685
|
exports.core = core;
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IRpc = exports.
|
|
3
|
+
exports.IRpc = exports.RpcMsg = void 0;
|
|
4
4
|
const IWebSocket_1 = require("./IWebSocket");
|
|
5
|
-
class
|
|
5
|
+
class RpcMsg extends IWebSocket_1.BaseMsg {
|
|
6
6
|
__rpcid = "";
|
|
7
7
|
__return = false;
|
|
8
|
+
/**
|
|
9
|
+
* 发送者分组
|
|
10
|
+
*/
|
|
11
|
+
from_group = "";
|
|
12
|
+
/**
|
|
13
|
+
* 发送者分组下的某个具体对象id
|
|
14
|
+
*/
|
|
15
|
+
from_id = "";
|
|
16
|
+
/**
|
|
17
|
+
* 必填,目的组
|
|
18
|
+
*/
|
|
19
|
+
to_group = "";
|
|
20
|
+
/**
|
|
21
|
+
* 目的分组下的某个具体对象id
|
|
22
|
+
*/
|
|
23
|
+
to_id = "";
|
|
24
|
+
/**
|
|
25
|
+
* 消息携带的数据
|
|
26
|
+
*/
|
|
27
|
+
data = null;
|
|
8
28
|
}
|
|
9
|
-
exports.
|
|
29
|
+
exports.RpcMsg = RpcMsg;
|
|
10
30
|
class IRpc {
|
|
11
31
|
}
|
|
12
32
|
exports.IRpc = IRpc;
|
|
@@ -6,19 +6,33 @@ const EventTool_1 = require("../Logic/EventTool");
|
|
|
6
6
|
const Log_1 = require("../Logic/Log");
|
|
7
7
|
const IClientWebSocket_1 = require("./IClientWebSocket");
|
|
8
8
|
class IRpcClientWebSocket extends IClientWebSocket_1.IClientWebSocket {
|
|
9
|
+
/**
|
|
10
|
+
* 自己的身份
|
|
11
|
+
*/
|
|
12
|
+
_group = "";
|
|
13
|
+
_id = "";
|
|
14
|
+
//超时时间
|
|
15
|
+
_timeout = 3000;
|
|
9
16
|
_genId(pre = "") {
|
|
10
17
|
return pre + "_" + Date.now() % 10000000000 + "_" + _.uniqueId() + _.random(9999999);
|
|
11
18
|
}
|
|
12
19
|
getNewMsg(cmd, errcode) {
|
|
13
20
|
let msg = super.getNewMsg(cmd, errcode);
|
|
14
21
|
msg.__rpcid = this._genId(cmd);
|
|
22
|
+
msg.from_group = this._group;
|
|
23
|
+
msg.from_id = this._id;
|
|
15
24
|
return msg;
|
|
16
25
|
}
|
|
17
|
-
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
toRetMsg(req_msg, data, errcode) {
|
|
27
|
+
let ret_msg = this.getNewMsg(req_msg.cmd, errcode);
|
|
28
|
+
//唯一标识必须保持一致
|
|
29
|
+
ret_msg.__rpcid = req_msg.__rpcid;
|
|
30
|
+
ret_msg.data = data;
|
|
31
|
+
ret_msg.from_group = this._group;
|
|
32
|
+
ret_msg.from_id = this._id;
|
|
33
|
+
ret_msg.to_group = req_msg.from_group;
|
|
34
|
+
ret_msg.to_id = req_msg.to_id;
|
|
35
|
+
return ret_msg;
|
|
22
36
|
}
|
|
23
37
|
async callRemote(msg) {
|
|
24
38
|
if (!msg) {
|
|
@@ -46,10 +60,6 @@ class IRpcClientWebSocket extends IClientWebSocket_1.IClientWebSocket {
|
|
|
46
60
|
});
|
|
47
61
|
}
|
|
48
62
|
receive_other_all(msg) {
|
|
49
|
-
if (msg.__return) {
|
|
50
|
-
EventTool_1.GEventTool.emit(msg.__rpcid, msg);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
63
|
Log_1.GLog.error({ des: "no handle", msg });
|
|
54
64
|
}
|
|
55
65
|
async _onMessage(msg) {
|
|
@@ -6,28 +6,45 @@ const EventTool_1 = require("../Logic/EventTool");
|
|
|
6
6
|
const Log_1 = require("../Logic/Log");
|
|
7
7
|
const IServerWebSocket_1 = require("./IServerWebSocket");
|
|
8
8
|
class IRpcServerWebSocket extends IServerWebSocket_1.IServerWebSocket {
|
|
9
|
+
/**
|
|
10
|
+
* 自己的身份
|
|
11
|
+
*/
|
|
12
|
+
_group = "";
|
|
13
|
+
_id = "";
|
|
14
|
+
//超时时间
|
|
15
|
+
_timeout = 3000;
|
|
16
|
+
constructor(group, id, timeout = 3000) {
|
|
17
|
+
super();
|
|
18
|
+
this._group = group;
|
|
19
|
+
this._id = id;
|
|
20
|
+
this._timeout = timeout || 3000;
|
|
21
|
+
}
|
|
9
22
|
_genId(pre = "") {
|
|
10
23
|
return pre + "_" + Date.now() % 10000000000 + "_" + _.uniqueId() + _.random(9999999);
|
|
11
24
|
}
|
|
12
25
|
getNewMsg(cmd, errcode) {
|
|
13
26
|
let msg = super.getNewMsg(cmd, errcode);
|
|
14
27
|
msg.__rpcid = this._genId(cmd);
|
|
28
|
+
msg.from_group = this._group;
|
|
29
|
+
msg.from_id = this._id;
|
|
15
30
|
return msg;
|
|
16
31
|
}
|
|
17
|
-
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
toRetMsg(req_msg, data, errcode) {
|
|
33
|
+
let ret_msg = this.getNewMsg(req_msg.cmd, errcode);
|
|
34
|
+
//唯一标识必须保持一致
|
|
35
|
+
ret_msg.__rpcid = req_msg.__rpcid;
|
|
36
|
+
ret_msg.data = data;
|
|
37
|
+
ret_msg.from_group = this._group;
|
|
38
|
+
ret_msg.from_id = this._id;
|
|
39
|
+
ret_msg.to_group = req_msg.from_group;
|
|
40
|
+
ret_msg.to_id = req_msg.to_id;
|
|
41
|
+
return ret_msg;
|
|
22
42
|
}
|
|
23
43
|
async callRemote(msg) {
|
|
24
44
|
if (!msg) {
|
|
25
45
|
Log_1.GLog.error("send null msg!");
|
|
26
46
|
return;
|
|
27
47
|
}
|
|
28
|
-
if (!msg.__rpcid) {
|
|
29
|
-
msg.__rpcid = this._genId(msg.cmd);
|
|
30
|
-
}
|
|
31
48
|
return new Promise((resolve, reject) => {
|
|
32
49
|
let handler = null;
|
|
33
50
|
let func = (jsonData) => {
|
|
@@ -39,17 +56,14 @@ class IRpcServerWebSocket extends IServerWebSocket_1.IServerWebSocket {
|
|
|
39
56
|
};
|
|
40
57
|
handler = setTimeout(() => {
|
|
41
58
|
EventTool_1.GEventTool.off(msg.__rpcid, func);
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
let error_msg = this.getNewMsg(msg.cmd, { id: 10086, des: "timeout" });
|
|
60
|
+
resolve(error_msg);
|
|
61
|
+
}, this._timeout);
|
|
44
62
|
EventTool_1.GEventTool.once(msg.__rpcid, func);
|
|
45
63
|
super.send(msg);
|
|
46
64
|
});
|
|
47
65
|
}
|
|
48
66
|
receive_other_all(msg) {
|
|
49
|
-
if (msg.__rpcid) {
|
|
50
|
-
EventTool_1.GEventTool.emit(msg.__rpcid, msg);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
67
|
Log_1.GLog.error({ des: "no handle", msg });
|
|
54
68
|
}
|
|
55
69
|
async _onMessage(msg) {
|
|
@@ -1,88 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CgMq = exports.
|
|
3
|
+
exports.CgMq = exports.RpcConfig = void 0;
|
|
4
4
|
const Core_1 = require("../Core/Core");
|
|
5
5
|
const Log_1 = require("../Logic/Log");
|
|
6
6
|
const IRpcServerWebSocket_1 = require("../SocketServer/IRpcServerWebSocket");
|
|
7
|
-
const IRpc_1 = require("../SocketServer/IRpc");
|
|
8
|
-
//接受到的消息无需basemsg部分
|
|
9
|
-
class CgMqMsg extends IRpc_1.RpcBaseMsg {
|
|
10
|
-
/**
|
|
11
|
-
* 必填,目的身份
|
|
12
|
-
*/
|
|
13
|
-
to_identity = "";
|
|
14
|
-
/**
|
|
15
|
-
* 消息携带的数据
|
|
16
|
-
*/
|
|
17
|
-
data = null;
|
|
18
|
-
}
|
|
19
|
-
class CgMqRetMsg extends CgMqMsg {
|
|
20
|
-
/**
|
|
21
|
-
* 发送者身份
|
|
22
|
-
*/
|
|
23
|
-
from_identity = "";
|
|
24
|
-
/**
|
|
25
|
-
* audience 数量
|
|
26
|
-
*/
|
|
27
|
-
count = 0;
|
|
28
|
-
}
|
|
29
|
-
exports.CgMqRetMsg = CgMqRetMsg;
|
|
30
7
|
class CgMqServerWebsocket extends IRpcServerWebSocket_1.IRpcServerWebSocket {
|
|
31
8
|
_cgmq = null;
|
|
32
|
-
/**
|
|
33
|
-
* 自己的身份
|
|
34
|
-
*/
|
|
35
|
-
_identity = "";
|
|
36
9
|
constructor(cgmq) {
|
|
37
|
-
super();
|
|
10
|
+
super(cgmq.cfg.group, cgmq.cfg.id, cgmq.cfg.timeout);
|
|
38
11
|
this._cgmq = cgmq;
|
|
39
|
-
this._identity = this._cgmq.cfg.identity;
|
|
40
12
|
this._debug_msg = true;
|
|
41
13
|
}
|
|
42
14
|
onOpen(e) {
|
|
43
|
-
this.init(
|
|
15
|
+
this.init();
|
|
44
16
|
}
|
|
45
|
-
async init(
|
|
17
|
+
async init() {
|
|
46
18
|
let msg = this.getNewMsg("init");
|
|
47
|
-
msg.identity = identity;
|
|
48
19
|
let jsonData = await this.callRemote(msg);
|
|
49
20
|
return jsonData;
|
|
50
21
|
}
|
|
51
|
-
|
|
22
|
+
//把消息发送给rpc服务器,目的是调用远程函数
|
|
23
|
+
async push(to_group, data, to_id = "") {
|
|
52
24
|
let msg = this.getNewMsg("msg");
|
|
53
|
-
msg.
|
|
25
|
+
msg.to_group = to_group;
|
|
26
|
+
msg.to_id = to_id;
|
|
54
27
|
msg.data = data;
|
|
55
28
|
let jsonData = await this.callRemote(msg);
|
|
56
29
|
return jsonData;
|
|
57
30
|
}
|
|
31
|
+
//收到来自远程的调用消息
|
|
58
32
|
async receive_msg(msg) {
|
|
59
33
|
let data = await this._cgmq.onMsg(msg);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
34
|
+
let ret_msg = this.getNewMsg("msg");
|
|
35
|
+
ret_msg.data = data;
|
|
36
|
+
ret_msg.__return = true;
|
|
37
|
+
//这个唯一标识必须和请求一致
|
|
38
|
+
ret_msg.__rpcid = msg.__rpcid;
|
|
39
|
+
ret_msg.to_group = msg.from_group;
|
|
40
|
+
ret_msg.to_id = msg.to_id;
|
|
64
41
|
this.send(msg);
|
|
65
42
|
}
|
|
66
43
|
}
|
|
67
|
-
class
|
|
68
|
-
|
|
44
|
+
class RpcConfig {
|
|
45
|
+
/**
|
|
46
|
+
* 当前rpc分组,一旦确认不可更改
|
|
47
|
+
*/
|
|
48
|
+
group = "";
|
|
49
|
+
/**
|
|
50
|
+
* 当前rpc唯一id,一旦确认不可更改
|
|
51
|
+
*/
|
|
52
|
+
id = "";
|
|
53
|
+
/**
|
|
54
|
+
* rpc超时时间,默认3000ms
|
|
55
|
+
*/
|
|
56
|
+
timeout = 0;
|
|
69
57
|
host = "";
|
|
70
58
|
port = -1;
|
|
71
59
|
}
|
|
72
|
-
exports.
|
|
60
|
+
exports.RpcConfig = RpcConfig;
|
|
73
61
|
class CgMq {
|
|
74
62
|
_ws = null;
|
|
75
63
|
_inited = false;
|
|
76
64
|
_cfg = null;
|
|
77
65
|
_onmsg = null;
|
|
66
|
+
get id() {
|
|
67
|
+
return this._cfg.id;
|
|
68
|
+
}
|
|
78
69
|
get cfg() {
|
|
79
70
|
return this._cfg;
|
|
80
71
|
}
|
|
81
|
-
get
|
|
82
|
-
return this._cfg?.
|
|
72
|
+
get group() {
|
|
73
|
+
return this._cfg?.group || "";
|
|
83
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @param cfg rpc服务器的配置
|
|
78
|
+
* @param onmsg
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
84
81
|
async init(cfg, onmsg) {
|
|
85
|
-
if (!cfg) {
|
|
82
|
+
if (!cfg || !cfg.group || !cfg.id) {
|
|
86
83
|
return false;
|
|
87
84
|
}
|
|
88
85
|
this._cfg = cfg;
|
|
@@ -113,13 +110,13 @@ class CgMq {
|
|
|
113
110
|
}
|
|
114
111
|
});
|
|
115
112
|
}
|
|
116
|
-
async callRemote(
|
|
113
|
+
async callRemote(group, to_id, func_name, ...args) {
|
|
117
114
|
let data = {
|
|
118
115
|
cmd: func_name,
|
|
119
116
|
args: args
|
|
120
117
|
};
|
|
121
|
-
let
|
|
122
|
-
return
|
|
118
|
+
let ret = (await this._ws.push(group, data, to_id));
|
|
119
|
+
return ret;
|
|
123
120
|
}
|
|
124
121
|
async onMsg(msg) {
|
|
125
122
|
if (this._onmsg) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Rpc =
|
|
3
|
+
exports.Rpc = void 0;
|
|
4
4
|
const Core_1 = require("../Core/Core");
|
|
5
5
|
const Log_1 = require("../Logic/Log");
|
|
6
6
|
const CgMq_1 = require("./CgMq");
|
|
@@ -13,26 +13,23 @@ class Remote {
|
|
|
13
13
|
get cgmq() {
|
|
14
14
|
return this._cgmq;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
_to_group = "";
|
|
17
|
+
_to_id = "";
|
|
18
|
+
constructor(group, id, cgmq) {
|
|
19
|
+
this._to_group = group;
|
|
20
|
+
this._to_id = id;
|
|
19
21
|
this._cgmq = cgmq;
|
|
20
22
|
}
|
|
21
23
|
async call(func_name, ...args) {
|
|
22
|
-
this._retmsg = await this._cgmq.callRemote(this.
|
|
23
|
-
if (!this._retmsg.data) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
24
|
+
this._retmsg = await this._cgmq.callRemote(this._to_group, this._to_id, func_name, ...args);
|
|
26
25
|
let datas = this._retmsg.data;
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
let ret = { rets: datas, ret: null };
|
|
27
|
+
if (datas && datas.length > 0) {
|
|
28
|
+
ret.ret = datas[0];
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return ret;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class RpcConfig extends CgMq_1.CgMqConfig {
|
|
34
|
-
}
|
|
35
|
-
exports.RpcConfig = RpcConfig;
|
|
36
33
|
class Rpc {
|
|
37
34
|
_cgmq = null;
|
|
38
35
|
get cgmq() {
|
|
@@ -43,8 +40,8 @@ class Rpc {
|
|
|
43
40
|
let ret = await this._cgmq.init(cfg, this.onMsg.bind(this));
|
|
44
41
|
return ret;
|
|
45
42
|
}
|
|
46
|
-
getRemote(
|
|
47
|
-
return new Remote(
|
|
43
|
+
getRemote(group, id = "") {
|
|
44
|
+
return new Remote(group, id, this._cgmq);
|
|
48
45
|
}
|
|
49
46
|
async onMsg(msg) {
|
|
50
47
|
if (!msg || !msg.data || !msg.data.cmd) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoCacheModel = exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.MongoAccountService = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.RedisManager = exports.GRedisMgr = exports.SqlReturns = exports.SqlReturn = exports.SqlResult = exports.GMysqlMgr = exports.MysqlBaseService = exports.GMSSqlMgr = exports.GMongoMgr = exports.MongoManager = exports.MongoBaseModel = exports.MysqlBaseModel = exports.MongoBaseService = exports.EPropertyType = exports.Type = exports.Table = exports.Property = exports.PrimaryKey = exports.NotNull = exports.AutoIncrement = exports.Timer = exports.core = exports.GServerCfg = exports.IServerConfig = exports.FrameworkConfig = exports.Config = exports.FrameworkErrorCode = exports.GTriggerMgr = exports.Trigger = exports.Point = exports.Entity = exports.BehaviorAI = exports.AStar = exports.AiObject = exports.GDBCache = exports.GCgServer = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.GByteTool = exports.SyncCallServer2 = exports.SyncCallServer = exports.SyncCall2 = exports.SyncCall = exports.IRpcClientWebSocket = exports.IRpcServerWebSocket =
|
|
4
|
+
exports.RpcConfig = exports.CgMq = exports.Rpc = exports.RpcBaseMsg = exports.EAccountState = exports.GEventTool = exports.GSyncQueueTool = exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.MysqlBaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.AlipayCallBack = exports.AlipayResult = exports.GAlipayTool = exports.BaseMsg = exports.IWebSocket = exports.ISocketServer = exports.IClientWebSocket = exports.IServerWebSocket = exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.EProtoType = exports.GProtoFactory = exports.RedisConfig = exports.MysqlConfig = exports.MongoConfig = exports.MSSqlConfig = exports.DbConfig = void 0;
|
|
5
|
+
exports.GByteTool = exports.SyncCallServer2 = exports.SyncCallServer = exports.SyncCall2 = exports.SyncCall = exports.IRpcClientWebSocket = exports.IRpcServerWebSocket = void 0;
|
|
6
6
|
var cgserver_1 = require("./cgserver");
|
|
7
7
|
Object.defineProperty(exports, "GCgServer", { enumerable: true, get: function () { return cgserver_1.GCgServer; } });
|
|
8
8
|
var DBCache_1 = require("./Database/Decorator/DBCache");
|
|
@@ -183,13 +183,12 @@ Object.defineProperty(exports, "GEventTool", { enumerable: true, get: function (
|
|
|
183
183
|
var ini_2 = require("./Service/ini");
|
|
184
184
|
Object.defineProperty(exports, "EAccountState", { enumerable: true, get: function () { return ini_2.EAccountState; } });
|
|
185
185
|
var IRpc_1 = require("./SocketServer/IRpc");
|
|
186
|
-
Object.defineProperty(exports, "RpcBaseMsg", { enumerable: true, get: function () { return IRpc_1.
|
|
186
|
+
Object.defineProperty(exports, "RpcBaseMsg", { enumerable: true, get: function () { return IRpc_1.RpcMsg; } });
|
|
187
187
|
var Rpc_1 = require("./ThirdParty/Rpc");
|
|
188
188
|
Object.defineProperty(exports, "Rpc", { enumerable: true, get: function () { return Rpc_1.Rpc; } });
|
|
189
|
-
Object.defineProperty(exports, "RpcConfig", { enumerable: true, get: function () { return Rpc_1.RpcConfig; } });
|
|
190
189
|
var CgMq_1 = require("./ThirdParty/CgMq");
|
|
191
190
|
Object.defineProperty(exports, "CgMq", { enumerable: true, get: function () { return CgMq_1.CgMq; } });
|
|
192
|
-
Object.defineProperty(exports, "
|
|
191
|
+
Object.defineProperty(exports, "RpcConfig", { enumerable: true, get: function () { return CgMq_1.RpcConfig; } });
|
|
193
192
|
var IRpcServerWebSocket_1 = require("./SocketServer/IRpcServerWebSocket");
|
|
194
193
|
Object.defineProperty(exports, "IRpcServerWebSocket", { enumerable: true, get: function () { return IRpcServerWebSocket_1.IRpcServerWebSocket; } });
|
|
195
194
|
var IRpcClientWebSocket_1 = require("./SocketServer/IRpcClientWebSocket");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RpcConfig } from "../ThirdParty/
|
|
1
|
+
import { RpcConfig } from "../ThirdParty/CgMq";
|
|
2
2
|
import { Config } from "./Config";
|
|
3
3
|
import { DbConfig } from "./DbConfig";
|
|
4
4
|
export declare enum ESessionType {
|
|
@@ -195,7 +195,7 @@ export declare class FrameworkConfig extends Config {
|
|
|
195
195
|
apple: {
|
|
196
196
|
keyIds: {};
|
|
197
197
|
};
|
|
198
|
-
|
|
198
|
+
cgrpc: RpcConfig;
|
|
199
199
|
};
|
|
200
200
|
ip_to_domain: {};
|
|
201
201
|
root_path: string;
|
|
@@ -110,4 +110,5 @@ export declare class core {
|
|
|
110
110
|
static getUuid(): string;
|
|
111
111
|
static signatureBase64(private_key: string, rsa_name: string, payload: string): any;
|
|
112
112
|
static signatureVerifyBase64(signature: string, private_key: string, rsa_name: string, payload: string): any;
|
|
113
|
+
static delay(milliseconds: number): Promise<unknown>;
|
|
113
114
|
}
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { BaseMsg } from "./IWebSocket";
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class RpcMsg extends BaseMsg {
|
|
3
3
|
__rpcid: string;
|
|
4
4
|
__return: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* 发送者分组
|
|
7
|
+
*/
|
|
8
|
+
from_group: string;
|
|
9
|
+
/**
|
|
10
|
+
* 发送者分组下的某个具体对象id
|
|
11
|
+
*/
|
|
12
|
+
from_id: string;
|
|
13
|
+
/**
|
|
14
|
+
* 必填,目的组
|
|
15
|
+
*/
|
|
16
|
+
to_group: string;
|
|
17
|
+
/**
|
|
18
|
+
* 目的分组下的某个具体对象id
|
|
19
|
+
*/
|
|
20
|
+
to_id: string;
|
|
21
|
+
/**
|
|
22
|
+
* 消息携带的数据
|
|
23
|
+
*/
|
|
24
|
+
data: any;
|
|
5
25
|
}
|
|
6
26
|
export declare abstract class IRpc {
|
|
7
|
-
abstract callRemote(msg:
|
|
27
|
+
abstract callRemote(msg: RpcMsg): any;
|
|
8
28
|
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { IRpc,
|
|
1
|
+
import { IRpc, RpcMsg } from "./IRpc";
|
|
2
2
|
import { IClientWebSocket } from "./IClientWebSocket";
|
|
3
3
|
export declare class IRpcClientWebSocket extends IClientWebSocket implements IRpc {
|
|
4
|
+
/**
|
|
5
|
+
* 自己的身份
|
|
6
|
+
*/
|
|
7
|
+
protected _group: string;
|
|
8
|
+
protected _id: string;
|
|
9
|
+
protected _timeout: number;
|
|
4
10
|
protected _genId(pre?: string): string;
|
|
5
11
|
getNewMsg(cmd: string, errcode?: {
|
|
6
12
|
id: number;
|
|
7
13
|
des: string;
|
|
8
|
-
}):
|
|
9
|
-
|
|
14
|
+
}): RpcMsg;
|
|
15
|
+
toRetMsg(req_msg: RpcMsg, data: any, errcode?: {
|
|
10
16
|
id: number;
|
|
11
17
|
des: string;
|
|
12
|
-
}):
|
|
13
|
-
callRemote(msg:
|
|
14
|
-
receive_other_all(msg:
|
|
15
|
-
protected _onMessage(msg:
|
|
18
|
+
}): RpcMsg;
|
|
19
|
+
callRemote(msg: RpcMsg): Promise<unknown>;
|
|
20
|
+
receive_other_all(msg: RpcMsg): void;
|
|
21
|
+
protected _onMessage(msg: RpcMsg): Promise<void>;
|
|
16
22
|
}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { IServerWebSocket } from "./IServerWebSocket";
|
|
2
|
-
import { IRpc,
|
|
2
|
+
import { IRpc, RpcMsg } from "./IRpc";
|
|
3
3
|
export declare class IRpcServerWebSocket extends IServerWebSocket implements IRpc {
|
|
4
|
+
/**
|
|
5
|
+
* 自己的身份
|
|
6
|
+
*/
|
|
7
|
+
protected _group: string;
|
|
8
|
+
protected _id: string;
|
|
9
|
+
protected _timeout: number;
|
|
10
|
+
constructor(group: string, id: string, timeout?: number);
|
|
4
11
|
protected _genId(pre?: string): string;
|
|
5
12
|
getNewMsg(cmd: string, errcode?: {
|
|
6
13
|
id: number;
|
|
7
14
|
des: string;
|
|
8
|
-
}):
|
|
9
|
-
|
|
15
|
+
}): RpcMsg;
|
|
16
|
+
toRetMsg(req_msg: RpcMsg, data: any, errcode?: {
|
|
10
17
|
id: number;
|
|
11
18
|
des: string;
|
|
12
|
-
}):
|
|
13
|
-
callRemote(msg:
|
|
14
|
-
receive_other_all(msg:
|
|
15
|
-
protected _onMessage(msg:
|
|
19
|
+
}): RpcMsg;
|
|
20
|
+
callRemote(msg: RpcMsg): Promise<RpcMsg>;
|
|
21
|
+
receive_other_all(msg: RpcMsg): void;
|
|
22
|
+
protected _onMessage(msg: RpcMsg): Promise<void>;
|
|
16
23
|
}
|
|
@@ -1,51 +1,45 @@
|
|
|
1
1
|
import { IRpcServerWebSocket } from "../SocketServer/IRpcServerWebSocket";
|
|
2
|
-
import {
|
|
3
|
-
declare class
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
data: any;
|
|
2
|
+
import { RpcMsg } from "../SocketServer/IRpc";
|
|
3
|
+
declare class CgMqServerWebsocket extends IRpcServerWebSocket {
|
|
4
|
+
protected _cgmq: CgMq;
|
|
5
|
+
constructor(cgmq: CgMq);
|
|
6
|
+
onOpen(e?: any): void;
|
|
7
|
+
init(): Promise<RpcMsg>;
|
|
8
|
+
push(to_group: string, data: any, to_id?: string): Promise<RpcMsg>;
|
|
9
|
+
receive_msg(msg: RpcMsg): Promise<void>;
|
|
12
10
|
}
|
|
13
|
-
export declare class
|
|
11
|
+
export declare class RpcConfig {
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
13
|
+
* 当前rpc分组,一旦确认不可更改
|
|
16
14
|
*/
|
|
17
|
-
|
|
15
|
+
group: string;
|
|
18
16
|
/**
|
|
19
|
-
*
|
|
17
|
+
* 当前rpc唯一id,一旦确认不可更改
|
|
20
18
|
*/
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
declare class CgMqServerWebsocket extends IRpcServerWebSocket {
|
|
24
|
-
protected _cgmq: CgMq;
|
|
19
|
+
id: string;
|
|
25
20
|
/**
|
|
26
|
-
*
|
|
21
|
+
* rpc超时时间,默认3000ms
|
|
27
22
|
*/
|
|
28
|
-
|
|
29
|
-
constructor(cgmq: CgMq);
|
|
30
|
-
onOpen(e?: any): void;
|
|
31
|
-
init(identity: string): Promise<unknown>;
|
|
32
|
-
push(to_identity: string, data: any): Promise<unknown>;
|
|
33
|
-
receive_msg(msg: CgMqRetMsg): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
export declare class CgMqConfig {
|
|
36
|
-
identity: string;
|
|
23
|
+
timeout: number;
|
|
37
24
|
host: string;
|
|
38
25
|
port: number;
|
|
39
26
|
}
|
|
40
27
|
export declare class CgMq {
|
|
41
28
|
protected _ws: CgMqServerWebsocket;
|
|
42
29
|
protected _inited: boolean;
|
|
43
|
-
protected _cfg:
|
|
44
|
-
protected _onmsg: (msg:
|
|
45
|
-
get
|
|
46
|
-
get
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
protected _cfg: RpcConfig;
|
|
31
|
+
protected _onmsg: (msg: RpcMsg) => any;
|
|
32
|
+
get id(): string;
|
|
33
|
+
get cfg(): RpcConfig;
|
|
34
|
+
get group(): string;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param cfg rpc服务器的配置
|
|
38
|
+
* @param onmsg
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
init(cfg: RpcConfig, onmsg?: (msg: RpcMsg) => any): Promise<unknown>;
|
|
42
|
+
callRemote(group: string, to_id: string, func_name: string, ...args: any[]): Promise<RpcMsg>;
|
|
43
|
+
onMsg(msg: RpcMsg): Promise<any>;
|
|
50
44
|
}
|
|
51
45
|
export {};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RpcMsg } from "../SocketServer/IRpc";
|
|
2
|
+
import { CgMq, RpcConfig } from "./CgMq";
|
|
2
3
|
declare class Remote {
|
|
3
|
-
protected _retmsg:
|
|
4
|
-
get retMsg():
|
|
4
|
+
protected _retmsg: RpcMsg;
|
|
5
|
+
get retMsg(): RpcMsg;
|
|
5
6
|
protected _cgmq: CgMq;
|
|
6
7
|
get cgmq(): CgMq;
|
|
7
|
-
protected
|
|
8
|
-
|
|
8
|
+
protected _to_group: string;
|
|
9
|
+
protected _to_id: string;
|
|
10
|
+
constructor(group: string, id: string, cgmq: CgMq);
|
|
9
11
|
call(func_name: string, ...args: any[]): Promise<any | any[]>;
|
|
10
12
|
}
|
|
11
|
-
export declare class RpcConfig extends CgMqConfig {
|
|
12
|
-
}
|
|
13
13
|
export declare class Rpc {
|
|
14
14
|
protected _cgmq: CgMq;
|
|
15
15
|
get cgmq(): CgMq;
|
|
16
16
|
init(cfg: RpcConfig): Promise<unknown>;
|
|
17
|
-
getRemote(
|
|
18
|
-
onMsg(msg:
|
|
17
|
+
getRemote(group: string, id?: string): Remote;
|
|
18
|
+
onMsg(msg: RpcMsg): Promise<any>;
|
|
19
19
|
}
|
|
20
20
|
export {};
|
|
@@ -82,9 +82,9 @@ export { WebServerConfig } from './Config/FrameworkConfig';
|
|
|
82
82
|
export { GSyncQueueTool } from './Logic/SyncQueueTool';
|
|
83
83
|
export { GEventTool } from './Logic/EventTool';
|
|
84
84
|
export { EAccountState } from './Service/ini';
|
|
85
|
-
export { RpcBaseMsg } from './SocketServer/IRpc';
|
|
86
|
-
export { Rpc
|
|
87
|
-
export { CgMq,
|
|
85
|
+
export { RpcMsg as RpcBaseMsg } from './SocketServer/IRpc';
|
|
86
|
+
export { Rpc } from './ThirdParty/Rpc';
|
|
87
|
+
export { CgMq, RpcConfig } from './ThirdParty/CgMq';
|
|
88
88
|
export { IRpcServerWebSocket } from './SocketServer/IRpcServerWebSocket';
|
|
89
89
|
export { IRpcClientWebSocket } from './SocketServer/IRpcClientWebSocket';
|
|
90
90
|
export { SyncCall, SyncCall2 } from './Decorator/SyncCall';
|