cgserver 6.7.445 → 6.8.447

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.
@@ -566,7 +566,7 @@ class core {
566
566
  });
567
567
  }
568
568
  static async safeCall(func, thisArg = null, ...params) {
569
- if (!func) {
569
+ if (!func || !core.isFunction(func)) {
570
570
  return;
571
571
  }
572
572
  try {
@@ -5,6 +5,11 @@ const IWebSocket_1 = require("./IWebSocket");
5
5
  const ws = require("websocket");
6
6
  const Log_1 = require("../Logic/Log");
7
7
  const IProtoFilter_1 = require("./ProtoFilter/IProtoFilter");
8
+ /**
9
+ * 客户端使用的websocket
10
+ * 用它去主动连接服务器
11
+ * 默认自动重连
12
+ */
8
13
  class IClientWebSocket extends IWebSocket_1.IWebSocket {
9
14
  _host = "";
10
15
  /**
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IRpcClientWebSocket = exports.RpcBaseMsg = void 0;
4
+ const _ = require("underscore");
5
+ const EventTool_1 = require("../Logic/EventTool");
6
+ const Log_1 = require("../Logic/Log");
7
+ const IClientWebSocket_1 = require("./IClientWebSocket");
8
+ const IWebSocket_1 = require("./IWebSocket");
9
+ class RpcBaseMsg extends IWebSocket_1.BaseMsg {
10
+ __rpcid = "";
11
+ }
12
+ exports.RpcBaseMsg = RpcBaseMsg;
13
+ class IRpcClientWebSocket extends IClientWebSocket_1.IClientWebSocket {
14
+ _genId(pre = "") {
15
+ return pre + "_" + Date.now() % 10000000000 + "_" + _.uniqueId() + _.random(9999999);
16
+ }
17
+ getNewMsg(cmd, errcode) {
18
+ let msg = super.getNewMsg(cmd, errcode);
19
+ msg.__rpcid = this._genId(cmd);
20
+ return msg;
21
+ }
22
+ async callRemote(msg) {
23
+ if (!msg) {
24
+ Log_1.GLog.error("send null msg!");
25
+ return;
26
+ }
27
+ if (!msg.__rpcid) {
28
+ msg.__rpcid = this._genId(msg.cmd);
29
+ }
30
+ return new Promise((resolve, reject) => {
31
+ let func = (jsonData) => {
32
+ resolve(jsonData);
33
+ };
34
+ let handler = setTimeout(() => {
35
+ EventTool_1.GEventTool.off(msg.__rpcid, func);
36
+ resolve({ errcode: { id: 10086, des: "timeout" } });
37
+ }, 3000);
38
+ EventTool_1.GEventTool.once(msg.__rpcid, func);
39
+ super.send(msg);
40
+ });
41
+ }
42
+ receive_other_all(jsonData) {
43
+ if (jsonData.__rpcid) {
44
+ EventTool_1.GEventTool.emit(jsonData.__rpcid, jsonData);
45
+ return;
46
+ }
47
+ Log_1.GLog.error({ des: "no handle", jsonData });
48
+ }
49
+ }
50
+ exports.IRpcClientWebSocket = IRpcClientWebSocket;
@@ -4,6 +4,10 @@ exports.IServerWebSocket = void 0;
4
4
  const IWebSocket_1 = require("./IWebSocket");
5
5
  const Log_1 = require("../Logic/Log");
6
6
  const IProtoFilter_1 = require("./ProtoFilter/IProtoFilter");
7
+ /**
8
+ * 服务器接收到的客户端的连接
9
+ * 客户端的session对象
10
+ */
7
11
  class IServerWebSocket extends IWebSocket_1.IWebSocket {
8
12
  _server = null;
9
13
  get server() {
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CgMq = exports.CgMqConfig = exports.CgMqRetMsg = void 0;
4
+ const Core_1 = require("../Core/Core");
5
+ const Log_1 = require("../Logic/Log");
6
+ const IRpcClientWebSocket_1 = require("../SocketServer/IRpcClientWebSocket");
7
+ //接受到的消息无需basemsg部分
8
+ class CgMqMsg extends IRpcClientWebSocket_1.RpcBaseMsg {
9
+ /**
10
+ * 必填,目的身份
11
+ */
12
+ to_identity = "";
13
+ /**
14
+ * 消息携带的数据
15
+ */
16
+ data = null;
17
+ }
18
+ class CgMqRetMsg extends CgMqMsg {
19
+ /**
20
+ * 发送者身份
21
+ */
22
+ from_identity = "";
23
+ /**
24
+ * audience 数量
25
+ */
26
+ count = 0;
27
+ }
28
+ exports.CgMqRetMsg = CgMqRetMsg;
29
+ class CgMqServerWebsocket extends IRpcClientWebSocket_1.IRpcClientWebSocket {
30
+ _cgmq = null;
31
+ /**
32
+ * 自己的身份
33
+ */
34
+ _identity = "";
35
+ constructor(cgmq) {
36
+ super();
37
+ this._cgmq = cgmq;
38
+ this._identity = this._cgmq.cfg.identity;
39
+ }
40
+ onOpen(e) {
41
+ this.init(this._cgmq.cfg.identity);
42
+ }
43
+ async init(identity) {
44
+ let msg = this.getNewMsg("init");
45
+ msg.identity = identity;
46
+ let jsonData = await this.callRemote(msg);
47
+ return jsonData;
48
+ }
49
+ async push(to_identity, data) {
50
+ let msg = this.getNewMsg("msg");
51
+ msg.to_identity = to_identity;
52
+ msg.data = data;
53
+ let jsonData = this.callRemote(msg);
54
+ return jsonData;
55
+ }
56
+ async receive_msg(msg) {
57
+ let data = await this._cgmq.onMsg(msg);
58
+ msg.data = data;
59
+ this.send(msg);
60
+ }
61
+ }
62
+ class CgMqConfig {
63
+ identity = "";
64
+ host = "";
65
+ port = -1;
66
+ }
67
+ exports.CgMqConfig = CgMqConfig;
68
+ class CgMq {
69
+ _ws = null;
70
+ _inited = false;
71
+ _cfg = null;
72
+ _onmsg = null;
73
+ get cfg() {
74
+ return this._cfg;
75
+ }
76
+ get identity() {
77
+ return this._cfg?.identity;
78
+ }
79
+ async init(cfg, onmsg) {
80
+ if (!cfg) {
81
+ return false;
82
+ }
83
+ this._cfg = cfg;
84
+ this._onmsg = onmsg;
85
+ if (this._inited) {
86
+ Log_1.GLog.error("dulplicate init for CgMq");
87
+ return true;
88
+ }
89
+ this._inited = true;
90
+ if (!this._ws) {
91
+ this._ws = new CgMqServerWebsocket(this);
92
+ }
93
+ return new Promise(async (resolve, reject) => {
94
+ this._ws.connect(cfg.host, cfg.port);
95
+ let pretime = Date.now();
96
+ while (true) {
97
+ if (this._ws.connected) {
98
+ resolve(true);
99
+ break;
100
+ }
101
+ let now = Date.now();
102
+ if (now - pretime >= 3 * 1000) {
103
+ this._ws.close();
104
+ resolve(false);
105
+ break;
106
+ }
107
+ await Core_1.core.sleep(100);
108
+ }
109
+ });
110
+ }
111
+ async callRemote(to_identity, func_name, ...args) {
112
+ let data = {
113
+ cmd: func_name,
114
+ args: args
115
+ };
116
+ let jsonData = await this._ws.push(to_identity, data);
117
+ return jsonData;
118
+ }
119
+ async onMsg(msg) {
120
+ if (this._onmsg) {
121
+ let data = await Core_1.core.safeCall(this._onmsg, msg);
122
+ return data;
123
+ }
124
+ return;
125
+ }
126
+ }
127
+ exports.CgMq = CgMq;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CgMq = exports.CgMqConfig = void 0;
4
+ const Core_1 = require("../Core/Core");
5
+ const Log_1 = require("../Logic/Log");
6
+ const IRpcClientWebSocket_1 = require("../SocketServer/IRpcClientWebSocket");
7
+ const _ = require("underscore");
8
+ //接受到的消息无需basemsg部分
9
+ class CgMqMsg extends IRpcClientWebSocket_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
+ class CgMqServerWebsocket extends IRpcClientWebSocket_1.IRpcClientWebSocket {
30
+ _cgmq = null;
31
+ /**
32
+ * 自己的身份
33
+ */
34
+ _identity = "";
35
+ constructor(cgmq) {
36
+ super();
37
+ this._cgmq = cgmq;
38
+ this._identity = this._cgmq.cfg.identity;
39
+ }
40
+ onOpen(e) {
41
+ this.listen(_.toArray(this._cgmq.listenIdentities));
42
+ }
43
+ //
44
+ async listen(identities) {
45
+ let msg = this.getNewMsg("listen");
46
+ msg.identities = identities;
47
+ let jsonData = await this.callRemote(msg);
48
+ return jsonData;
49
+ }
50
+ async cancelListen(identity) {
51
+ let msg = this.getNewMsg("cancelListen");
52
+ msg.identity = identity;
53
+ let jsonData = this.callRemote(msg);
54
+ return jsonData;
55
+ }
56
+ push(to_identity, data) {
57
+ let msg = this.getNewMsg("msg");
58
+ msg.to_identity = to_identity;
59
+ msg.data = data;
60
+ this.send(msg);
61
+ }
62
+ }
63
+ class CgMqConfig {
64
+ identity = "";
65
+ host = "";
66
+ port = -1;
67
+ }
68
+ exports.CgMqConfig = CgMqConfig;
69
+ class CgMq {
70
+ _ws = null;
71
+ _inited = false;
72
+ _cfg = null;
73
+ get cfg() {
74
+ return this._cfg;
75
+ }
76
+ get identity() {
77
+ return this._cfg?.identity;
78
+ }
79
+ //用kv方便查一些
80
+ _listen_identities = {};
81
+ get listenIdentities() {
82
+ return this._listen_identities;
83
+ }
84
+ async init(cfg, identities) {
85
+ if (!cfg) {
86
+ return false;
87
+ }
88
+ for (let key in identities) {
89
+ let id = identities[key];
90
+ this._listen_identities[id] = id;
91
+ }
92
+ this._cfg = cfg;
93
+ if (this._inited) {
94
+ Log_1.GLog.error("dulplicate init for CgMq");
95
+ return true;
96
+ }
97
+ this._inited = true;
98
+ if (!this._ws) {
99
+ this._ws = new CgMqServerWebsocket(this);
100
+ }
101
+ return new Promise(async (resolve, reject) => {
102
+ this._ws.connect(cfg.host, cfg.port);
103
+ let pretime = Date.now();
104
+ while (true) {
105
+ if (this._ws.connected) {
106
+ resolve(true);
107
+ break;
108
+ }
109
+ let now = Date.now();
110
+ if (now - pretime >= 3 * 1000) {
111
+ this._ws.close();
112
+ resolve(false);
113
+ break;
114
+ }
115
+ await Core_1.core.sleep(100);
116
+ }
117
+ });
118
+ }
119
+ async listen(identity) {
120
+ if (this._listen_identities[identity]) {
121
+ return true;
122
+ }
123
+ if (!this._ws || !this._ws.connected) {
124
+ return false;
125
+ }
126
+ let ret = this._ws.listen([identity]);
127
+ return ret;
128
+ }
129
+ async cancelListen(identity) {
130
+ if (this._listen_identities[identity]) {
131
+ return true;
132
+ }
133
+ if (!this._ws || !this._ws.connected) {
134
+ return false;
135
+ }
136
+ let ret = await this._ws.cancelListen(identity);
137
+ return ret;
138
+ }
139
+ }
140
+ exports.CgMq = CgMq;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Rpc = exports.RpcConfig = void 0;
4
+ const Core_1 = require("../Core/Core");
5
+ const Log_1 = require("../Logic/Log");
6
+ const CgMq_1 = require("./CgMq");
7
+ class Remote {
8
+ _cgmq = null;
9
+ get cgmq() {
10
+ return this._cgmq;
11
+ }
12
+ _to_identity = "";
13
+ constructor(identity, cgmq) {
14
+ this._to_identity = identity;
15
+ this._cgmq = cgmq;
16
+ }
17
+ async call(func_name, ...args) {
18
+ let jsonData = await this._cgmq.callRemote(this._to_identity, func_name, ...args);
19
+ return jsonData;
20
+ }
21
+ }
22
+ class RpcConfig extends CgMq_1.CgMqConfig {
23
+ }
24
+ exports.RpcConfig = RpcConfig;
25
+ class Rpc {
26
+ _cgmq = null;
27
+ get cgmq() {
28
+ return this._cgmq;
29
+ }
30
+ async init(cfg) {
31
+ this._cgmq = new CgMq_1.CgMq();
32
+ let ret = await this._cgmq.init(cfg, this.onMsg.bind(this));
33
+ return ret;
34
+ }
35
+ getRemote(identity) {
36
+ return new Remote(identity, this._cgmq);
37
+ }
38
+ async onMsg(msg) {
39
+ if (!msg || !msg.data || !msg.data.cmd) {
40
+ return;
41
+ }
42
+ let cmd = msg.data.cmd;
43
+ let func = this[cmd];
44
+ if (!func) {
45
+ Log_1.GLog.error({ des: "rpc no cmd", msg });
46
+ return;
47
+ }
48
+ let data = await Core_1.core.safeCall(func);
49
+ return data;
50
+ }
51
+ }
52
+ exports.Rpc = Rpc;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GRpcTool = void 0;
4
+ class Remote {
5
+ call(func_name, ...args) {
6
+ }
7
+ }
8
+ class RpcTool {
9
+ _cgmq;
10
+ async init() {
11
+ }
12
+ }
13
+ exports.GRpcTool = new RpcTool();
package/dist/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GoogleProtoFilter = exports.MongoCacheModel = exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.GMongoAccountSer = exports.MongoAccountService = exports.GMysqlAccountSer = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.RedisManager = exports.GRedisMgr = exports.GMysqlMgr = exports.MysqlBaseService = exports.GMSSqlMgr = exports.GMongoMgr = 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.ServerConfig = exports.FrameworkConfig = exports.Config = exports.FrameworkErrorCode = exports.GTriggerMgr = exports.Trigger = exports.Point = exports.Entity = exports.BehaviorAI = exports.AStar = exports.AiObject = exports.GDBCache = exports.GProtoFactory = exports.GCgServer = void 0;
4
- 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.BaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.GAlipayTool = exports.IWebSocket = exports.ISocketServer = exports.IServerWebSocket = exports.IClientWebSocket = exports.JsonProtoFilter = void 0;
4
+ exports.CgMqConfig = exports.CgMq = exports.RpcConfig = exports.Rpc = 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.BaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.GAlipayTool = exports.IWebSocket = exports.ISocketServer = exports.IServerWebSocket = exports.IClientWebSocket = exports.JsonProtoFilter = void 0;
5
5
  var cgserver_1 = require("./cgserver");
6
6
  Object.defineProperty(exports, "GCgServer", { enumerable: true, get: function () { return cgserver_1.GCgServer; } });
7
7
  var ProtoFactory_1 = require("./SocketServer/ProtoFilter/ProtoFactory");
@@ -164,3 +164,9 @@ var EventTool_1 = require("./Logic/EventTool");
164
164
  Object.defineProperty(exports, "GEventTool", { enumerable: true, get: function () { return EventTool_1.GEventTool; } });
165
165
  var ini_2 = require("./Service/ini");
166
166
  Object.defineProperty(exports, "EAccountState", { enumerable: true, get: function () { return ini_2.EAccountState; } });
167
+ var Rpc_1 = require("./ThirdParty/Rpc");
168
+ Object.defineProperty(exports, "Rpc", { enumerable: true, get: function () { return Rpc_1.Rpc; } });
169
+ Object.defineProperty(exports, "RpcConfig", { enumerable: true, get: function () { return Rpc_1.RpcConfig; } });
170
+ var CgMq_1 = require("./ThirdParty/CgMq");
171
+ Object.defineProperty(exports, "CgMq", { enumerable: true, get: function () { return CgMq_1.CgMq; } });
172
+ Object.defineProperty(exports, "CgMqConfig", { enumerable: true, get: function () { return CgMq_1.CgMqConfig; } });
@@ -99,6 +99,6 @@ export declare class core {
99
99
  * @param num
100
100
  */
101
101
  static convertToGlobalStr(num: number): string;
102
- static sleep(milliseconds: any): Promise<unknown>;
102
+ static sleep(milliseconds: number): Promise<unknown>;
103
103
  static safeCall(func: Function, thisArg?: any, ...params: any[]): Promise<any>;
104
104
  }
@@ -1,6 +1,11 @@
1
1
  import { IWebSocket } from './IWebSocket';
2
2
  import * as ws from 'websocket';
3
3
  import { EProtoType } from './ProtoFilter/IProtoFilter';
4
+ /**
5
+ * 客户端使用的websocket
6
+ * 用它去主动连接服务器
7
+ * 默认自动重连
8
+ */
4
9
  export declare class IClientWebSocket extends IWebSocket {
5
10
  protected _host: string;
6
11
  /**
@@ -0,0 +1,14 @@
1
+ import { IClientWebSocket } from "./IClientWebSocket";
2
+ import { BaseMsg } from "./IWebSocket";
3
+ export declare class RpcBaseMsg extends BaseMsg {
4
+ __rpcid: string;
5
+ }
6
+ export declare class IRpcClientWebSocket extends IClientWebSocket {
7
+ protected _genId(pre?: string): string;
8
+ getNewMsg(cmd: string, errcode?: {
9
+ id: number;
10
+ des: string;
11
+ }): any;
12
+ callRemote(msg: RpcBaseMsg): Promise<unknown>;
13
+ receive_other_all(jsonData: any): void;
14
+ }
@@ -2,6 +2,10 @@ import { ISocketServer } from './ISocketServer';
2
2
  import { IWebSocket } from './IWebSocket';
3
3
  import { EProtoType } from './ProtoFilter/IProtoFilter';
4
4
  import * as ws from 'websocket';
5
+ /**
6
+ * 服务器接收到的客户端的连接
7
+ * 客户端的session对象
8
+ */
5
9
  export declare class IServerWebSocket extends IWebSocket {
6
10
  protected _server: ISocketServer;
7
11
  get server(): ISocketServer;
@@ -37,7 +37,7 @@ export declare class IWebSocket {
37
37
  getNewMsg(cmd: string, errcode?: {
38
38
  id: number;
39
39
  des: string;
40
- }): BaseMsg;
40
+ }): BaseMsg | any;
41
41
  receive_heartbeat(jsonData: any): void;
42
42
  send_heartbeat(): void;
43
43
  onConnect(_ws: ws.connection): void;
@@ -0,0 +1,50 @@
1
+ import { IRpcClientWebSocket, RpcBaseMsg } from "../SocketServer/IRpcClientWebSocket";
2
+ declare class CgMqMsg extends RpcBaseMsg {
3
+ /**
4
+ * 必填,目的身份
5
+ */
6
+ to_identity: string;
7
+ /**
8
+ * 消息携带的数据
9
+ */
10
+ data: any;
11
+ }
12
+ export declare class CgMqRetMsg extends CgMqMsg {
13
+ /**
14
+ * 发送者身份
15
+ */
16
+ from_identity: string;
17
+ /**
18
+ * audience 数量
19
+ */
20
+ count: number;
21
+ }
22
+ declare class CgMqServerWebsocket extends IRpcClientWebSocket {
23
+ protected _cgmq: CgMq;
24
+ /**
25
+ * 自己的身份
26
+ */
27
+ protected _identity: string;
28
+ constructor(cgmq: CgMq);
29
+ onOpen(e?: any): void;
30
+ init(identity: string): Promise<unknown>;
31
+ push(to_identity: string, data: any): Promise<unknown>;
32
+ receive_msg(msg: CgMqRetMsg): Promise<void>;
33
+ }
34
+ export declare class CgMqConfig {
35
+ identity: string;
36
+ host: string;
37
+ port: number;
38
+ }
39
+ export declare class CgMq {
40
+ protected _ws: CgMqServerWebsocket;
41
+ protected _inited: boolean;
42
+ protected _cfg: CgMqConfig;
43
+ protected _onmsg: (msg: CgMqRetMsg) => any;
44
+ get cfg(): CgMqConfig;
45
+ get identity(): string;
46
+ init(cfg: CgMqConfig, onmsg?: (msg: CgMqRetMsg) => any): Promise<unknown>;
47
+ callRemote(to_identity: string, func_name: string, ...args: any[]): Promise<unknown>;
48
+ onMsg(msg: CgMqRetMsg): Promise<any>;
49
+ }
50
+ export {};
@@ -0,0 +1,35 @@
1
+ import { IRpcClientWebSocket } from "../SocketServer/IRpcClientWebSocket";
2
+ declare class CgMqServerWebsocket extends IRpcClientWebSocket {
3
+ protected _cgmq: CgMq;
4
+ /**
5
+ * 自己的身份
6
+ */
7
+ protected _identity: string;
8
+ constructor(cgmq: CgMq);
9
+ onOpen(e?: any): void;
10
+ listen(identities: string[]): Promise<unknown>;
11
+ cancelListen(identity: string): Promise<unknown>;
12
+ push(to_identity: string, data: any): void;
13
+ }
14
+ export declare class CgMqConfig {
15
+ identity: string;
16
+ host: string;
17
+ port: number;
18
+ }
19
+ export declare class CgMq {
20
+ protected _ws: CgMqServerWebsocket;
21
+ protected _inited: boolean;
22
+ protected _cfg: CgMqConfig;
23
+ get cfg(): CgMqConfig;
24
+ get identity(): string;
25
+ protected _listen_identities: {
26
+ [identity: string]: string;
27
+ };
28
+ get listenIdentities(): {
29
+ [identity: string]: string;
30
+ };
31
+ init(cfg: CgMqConfig, identities: string[]): Promise<unknown>;
32
+ listen(identity: string): Promise<unknown>;
33
+ cancelListen(identity: string): Promise<unknown>;
34
+ }
35
+ export {};
@@ -0,0 +1,18 @@
1
+ import { CgMq, CgMqConfig, CgMqRetMsg } from "./CgMq";
2
+ declare class Remote {
3
+ protected _cgmq: CgMq;
4
+ get cgmq(): CgMq;
5
+ protected _to_identity: string;
6
+ constructor(identity: string, cgmq: CgMq);
7
+ call(func_name: string, ...args: any[]): Promise<unknown>;
8
+ }
9
+ export declare class RpcConfig extends CgMqConfig {
10
+ }
11
+ export declare class Rpc {
12
+ protected _cgmq: CgMq;
13
+ get cgmq(): CgMq;
14
+ init(cfg: RpcConfig): Promise<unknown>;
15
+ getRemote(identity: string): Remote;
16
+ onMsg(msg: CgMqRetMsg): Promise<any>;
17
+ }
18
+ export {};
@@ -0,0 +1,6 @@
1
+ declare class RpcTool {
2
+ protected _cgmq: any;
3
+ init(): Promise<void>;
4
+ }
5
+ export declare let GRpcTool: RpcTool;
6
+ export {};
@@ -76,3 +76,5 @@ export { WebServerConfig } from './Config/FrameworkConfig';
76
76
  export { GSyncQueueTool } from './Logic/SyncQueueTool';
77
77
  export { GEventTool } from './Logic/EventTool';
78
78
  export { EAccountState } from './Service/ini';
79
+ export { Rpc, RpcConfig } from './ThirdParty/Rpc';
80
+ export { CgMq, CgMqConfig } from './ThirdParty/CgMq';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "6.7.445",
3
+ "version": "6.8.447",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",