cgserver 11.2.7 → 11.2.9
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.
|
@@ -6,13 +6,19 @@ const IRpcServerWebSocket_1 = require("../SocketServer/IRpcServerWebSocket");
|
|
|
6
6
|
const Log_1 = require("../Logic/Log");
|
|
7
7
|
class CgMqServerWebsocket extends IRpcServerWebSocket_1.IRpcServerWebSocket {
|
|
8
8
|
_cgmq = null;
|
|
9
|
+
_listens = {};
|
|
10
|
+
get listens() {
|
|
11
|
+
return this._listens;
|
|
12
|
+
}
|
|
9
13
|
constructor(cgmq) {
|
|
10
14
|
super(cgmq.cfg.group, cgmq.cfg.id, cgmq.cfg.timeout);
|
|
11
15
|
this._cgmq = cgmq;
|
|
12
16
|
this._debug_msg = true;
|
|
13
17
|
}
|
|
14
18
|
onOpen(e) {
|
|
19
|
+
super.onOpen(e);
|
|
15
20
|
this.init();
|
|
21
|
+
this.listen(Object.keys(this._listens));
|
|
16
22
|
}
|
|
17
23
|
async init() {
|
|
18
24
|
let msg = this.getNewMsg("init");
|
|
@@ -20,12 +26,26 @@ class CgMqServerWebsocket extends IRpcServerWebSocket_1.IRpcServerWebSocket {
|
|
|
20
26
|
return jsonData;
|
|
21
27
|
}
|
|
22
28
|
async listen(data) {
|
|
29
|
+
for (let i = 0; i < data.length; i++) {
|
|
30
|
+
let listen = data[i];
|
|
31
|
+
if (!listen) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
this._listens[listen] = true;
|
|
35
|
+
}
|
|
23
36
|
let msg = this.getNewMsg("listen");
|
|
24
37
|
msg.data = data;
|
|
25
38
|
let jsonData = await this.callRemote(msg);
|
|
26
39
|
return jsonData;
|
|
27
40
|
}
|
|
28
41
|
async unlisten(data) {
|
|
42
|
+
for (let i = 0; i < data.length; i++) {
|
|
43
|
+
let listen = data[i];
|
|
44
|
+
if (!listen) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
delete this._listens[listen];
|
|
48
|
+
}
|
|
29
49
|
let msg = this.getNewMsg("unlisten");
|
|
30
50
|
msg.data = data;
|
|
31
51
|
let jsonData = await this.callRemote(msg);
|
|
@@ -70,6 +90,12 @@ class CgMq {
|
|
|
70
90
|
get ws() {
|
|
71
91
|
return this._ws;
|
|
72
92
|
}
|
|
93
|
+
get listens() {
|
|
94
|
+
if (!this._ws) {
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
return this._ws.listens;
|
|
98
|
+
}
|
|
73
99
|
_inited = false;
|
|
74
100
|
_cfg = null;
|
|
75
101
|
_onmsg = null;
|
|
@@ -2,6 +2,12 @@ import { IRpcServerWebSocket } from "../SocketServer/IRpcServerWebSocket";
|
|
|
2
2
|
import { RpcMsg } from "../SocketServer/IRpc";
|
|
3
3
|
declare class CgMqServerWebsocket extends IRpcServerWebSocket {
|
|
4
4
|
protected _cgmq: CgMq;
|
|
5
|
+
protected _listens: {
|
|
6
|
+
[listen: string]: boolean;
|
|
7
|
+
};
|
|
8
|
+
get listens(): {
|
|
9
|
+
[listen: string]: boolean;
|
|
10
|
+
};
|
|
5
11
|
constructor(cgmq: CgMq);
|
|
6
12
|
onOpen(e?: any): void;
|
|
7
13
|
init(): Promise<RpcMsg>;
|
|
@@ -29,6 +35,9 @@ export declare class RpcConfig {
|
|
|
29
35
|
export declare class CgMq {
|
|
30
36
|
protected _ws: CgMqServerWebsocket;
|
|
31
37
|
get ws(): CgMqServerWebsocket;
|
|
38
|
+
get listens(): {
|
|
39
|
+
[listen: string]: boolean;
|
|
40
|
+
};
|
|
32
41
|
protected _inited: boolean;
|
|
33
42
|
protected _cfg: RpcConfig;
|
|
34
43
|
protected _onmsg: (msg: RpcMsg) => any;
|
|
@@ -41,7 +50,7 @@ export declare class CgMq {
|
|
|
41
50
|
* @param onmsg
|
|
42
51
|
* @returns
|
|
43
52
|
*/
|
|
44
|
-
init(cfg: RpcConfig, onmsg?: (msg: RpcMsg) => any): Promise<
|
|
53
|
+
init(cfg: RpcConfig, onmsg?: (msg: RpcMsg) => any): Promise<boolean>;
|
|
45
54
|
callRemote(group: string, to_id: string, listen: string, func_name: string, ...args: any[]): Promise<RpcMsg>;
|
|
46
55
|
onMsg(msg: RpcMsg): Promise<any>;
|
|
47
56
|
listen(data: string[]): Promise<RpcMsg>;
|
|
@@ -17,7 +17,7 @@ declare class Remote {
|
|
|
17
17
|
export declare class Rpc {
|
|
18
18
|
protected _cgmq: CgMq;
|
|
19
19
|
get cgmq(): CgMq;
|
|
20
|
-
init(cfg: RpcConfig): Promise<
|
|
20
|
+
init(cfg: RpcConfig): Promise<boolean>;
|
|
21
21
|
getRemote(group: string, id?: string, listener?: string): Remote;
|
|
22
22
|
onMsg(msg: RpcMsg): Promise<any>;
|
|
23
23
|
listen(listeners: string[]): Promise<RpcMsg>;
|