cgserver 11.0.0 → 11.2.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/dist/lib/Framework/SocketServer/IRpcClientWebSocket.js +6 -0
- package/dist/lib/Framework/ThirdParty/CgMq.js +9 -3
- package/dist/lib/Framework/ThirdParty/Rpc.js +14 -4
- package/dist/types/Framework/SocketServer/IRpcClientWebSocket.d.ts +1 -0
- package/dist/types/Framework/ThirdParty/CgMq.d.ts +3 -1
- package/dist/types/Framework/ThirdParty/Rpc.d.ts +5 -2
- package/package.json +1 -1
|
@@ -14,6 +14,12 @@ class IRpcClientWebSocket extends IClientWebSocket_1.IClientWebSocket {
|
|
|
14
14
|
//超时时间
|
|
15
15
|
_timeout = 3000;
|
|
16
16
|
_listens = {};
|
|
17
|
+
isListenning(listen) {
|
|
18
|
+
if (!listen) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return !!this._listens[listen];
|
|
22
|
+
}
|
|
17
23
|
_genId(pre = "") {
|
|
18
24
|
return pre + "_" + Core_1.core.getUuid();
|
|
19
25
|
}
|
|
@@ -117,15 +117,15 @@ class CgMq {
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
async callRemote(group, to_id, func_name, ...args) {
|
|
120
|
+
async callRemote(group, to_id, listen, func_name, ...args) {
|
|
121
121
|
let time = Date.now();
|
|
122
122
|
let data = {
|
|
123
123
|
cmd: func_name,
|
|
124
124
|
args: args
|
|
125
125
|
};
|
|
126
|
-
let ret_rpcmsg = await this._ws.push(group, data, to_id);
|
|
126
|
+
let ret_rpcmsg = await this._ws.push(group, data, to_id, listen);
|
|
127
127
|
if (this._ws.debug_msg) {
|
|
128
|
-
Log_1.gLog.info("[" + (Date.now() - time) + "ms] callRemote:" + group + "-" + func_name);
|
|
128
|
+
Log_1.gLog.info("[" + (Date.now() - time) + "ms] callRemote:" + group + "-" + func_name + "-" + listen);
|
|
129
129
|
}
|
|
130
130
|
return ret_rpcmsg;
|
|
131
131
|
}
|
|
@@ -136,5 +136,11 @@ class CgMq {
|
|
|
136
136
|
}
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
|
+
async listen(data) {
|
|
140
|
+
return await this._ws.listen(data);
|
|
141
|
+
}
|
|
142
|
+
async unlisten(data) {
|
|
143
|
+
return await this._ws.unlisten(data);
|
|
144
|
+
}
|
|
139
145
|
}
|
|
140
146
|
exports.CgMq = CgMq;
|
|
@@ -15,13 +15,15 @@ class Remote {
|
|
|
15
15
|
}
|
|
16
16
|
_to_group = "";
|
|
17
17
|
_to_id = "";
|
|
18
|
-
|
|
18
|
+
_listen = "";
|
|
19
|
+
constructor(group, id, cgmq, listen) {
|
|
19
20
|
this._to_group = group;
|
|
20
21
|
this._to_id = id;
|
|
22
|
+
this._listen = listen;
|
|
21
23
|
this._cgmq = cgmq;
|
|
22
24
|
}
|
|
23
25
|
async call(func_name, ...args) {
|
|
24
|
-
this._retmsg = await this._cgmq.callRemote(this._to_group, this._to_id, func_name, ...args);
|
|
26
|
+
this._retmsg = await this._cgmq.callRemote(this._to_group, this._to_id, this._listen, func_name, ...args);
|
|
25
27
|
let datas = this._retmsg.data;
|
|
26
28
|
let ret = { rets: datas, ret: null };
|
|
27
29
|
if (datas && datas.length > 0) {
|
|
@@ -40,8 +42,8 @@ class Rpc {
|
|
|
40
42
|
let ret = await this._cgmq.init(cfg, this.onMsg.bind(this));
|
|
41
43
|
return ret;
|
|
42
44
|
}
|
|
43
|
-
getRemote(group, id = "") {
|
|
44
|
-
return new Remote(group, id, this._cgmq);
|
|
45
|
+
getRemote(group, id = "", listener = "") {
|
|
46
|
+
return new Remote(group, id, this._cgmq, listener);
|
|
45
47
|
}
|
|
46
48
|
async onMsg(msg) {
|
|
47
49
|
if (!msg || !msg.data || !msg.data.cmd) {
|
|
@@ -56,5 +58,13 @@ class Rpc {
|
|
|
56
58
|
let data = await Core_1.core.safeCall(func, this, ...msg.data?.args, msg);
|
|
57
59
|
return data;
|
|
58
60
|
}
|
|
61
|
+
async listen(listeners) {
|
|
62
|
+
let ret = await this._cgmq.listen(listeners);
|
|
63
|
+
return ret;
|
|
64
|
+
}
|
|
65
|
+
async unlisten(listeners) {
|
|
66
|
+
let ret = await this._cgmq.unlisten(listeners);
|
|
67
|
+
return ret;
|
|
68
|
+
}
|
|
59
69
|
}
|
|
60
70
|
exports.Rpc = Rpc;
|
|
@@ -10,6 +10,7 @@ export declare class IRpcClientWebSocket extends IClientWebSocket implements IRp
|
|
|
10
10
|
protected _listens: {
|
|
11
11
|
[key: string]: boolean;
|
|
12
12
|
};
|
|
13
|
+
isListenning(listen: string): boolean;
|
|
13
14
|
protected _genId(pre?: string): string;
|
|
14
15
|
getNewMsg(cmd: string, errcode?: {
|
|
15
16
|
id: number;
|
|
@@ -41,7 +41,9 @@ export declare class CgMq {
|
|
|
41
41
|
* @returns
|
|
42
42
|
*/
|
|
43
43
|
init(cfg: RpcConfig, onmsg?: (msg: RpcMsg) => any): Promise<unknown>;
|
|
44
|
-
callRemote(group: string, to_id: string, func_name: string, ...args: any[]): Promise<RpcMsg>;
|
|
44
|
+
callRemote(group: string, to_id: string, listen: string, func_name: string, ...args: any[]): Promise<RpcMsg>;
|
|
45
45
|
onMsg(msg: RpcMsg): Promise<any>;
|
|
46
|
+
listen(data: string[]): Promise<RpcMsg>;
|
|
47
|
+
unlisten(data: string[]): Promise<RpcMsg>;
|
|
46
48
|
}
|
|
47
49
|
export {};
|
|
@@ -7,7 +7,8 @@ declare class Remote {
|
|
|
7
7
|
get cgmq(): CgMq;
|
|
8
8
|
protected _to_group: string;
|
|
9
9
|
protected _to_id: string;
|
|
10
|
-
|
|
10
|
+
protected _listen: string;
|
|
11
|
+
constructor(group: string, id: string, cgmq: CgMq, listen: string);
|
|
11
12
|
call(func_name: string, ...args: any[]): Promise<{
|
|
12
13
|
rets: any[];
|
|
13
14
|
ret: any;
|
|
@@ -17,7 +18,9 @@ export declare class Rpc {
|
|
|
17
18
|
protected _cgmq: CgMq;
|
|
18
19
|
get cgmq(): CgMq;
|
|
19
20
|
init(cfg: RpcConfig): Promise<unknown>;
|
|
20
|
-
getRemote(group: string, id?: string): Remote;
|
|
21
|
+
getRemote(group: string, id?: string, listener?: string): Remote;
|
|
21
22
|
onMsg(msg: RpcMsg): Promise<any>;
|
|
23
|
+
listen(listeners: string[]): Promise<RpcMsg>;
|
|
24
|
+
unlisten(listeners: string[]): Promise<RpcMsg>;
|
|
22
25
|
}
|
|
23
26
|
export {};
|