cgserver 6.9.466 → 6.9.468

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.
@@ -14,6 +14,12 @@ class IRpcClientWebSocket extends IClientWebSocket_1.IClientWebSocket {
14
14
  msg.__rpcid = this._genId(cmd);
15
15
  return msg;
16
16
  }
17
+ extendRetMsg(msg, errcode) {
18
+ let basemsg = super.getNewMsg(msg.cmd, errcode);
19
+ basemsg.__rpcid = msg.__rpcid;
20
+ _.extend(msg, basemsg);
21
+ return msg;
22
+ }
17
23
  async callRemote(msg) {
18
24
  if (!msg) {
19
25
  Log_1.GLog.error("send null msg!");
@@ -14,6 +14,12 @@ class IRpcServerWebSocket extends IServerWebSocket_1.IServerWebSocket {
14
14
  msg.__rpcid = this._genId(cmd);
15
15
  return msg;
16
16
  }
17
+ extendRetMsg(msg, errcode) {
18
+ let basemsg = super.getNewMsg(msg.cmd, errcode);
19
+ basemsg.__rpcid = msg.__rpcid;
20
+ _.extend(msg, basemsg);
21
+ return msg;
22
+ }
17
23
  async callRemote(msg) {
18
24
  if (!msg) {
19
25
  Log_1.GLog.error("send null msg!");
@@ -118,7 +118,7 @@ class CgMq {
118
118
  cmd: func_name,
119
119
  args: args
120
120
  };
121
- let jsonData = await this._ws.push(to_identity, data);
121
+ let jsonData = (await this._ws.push(to_identity, data));
122
122
  return jsonData;
123
123
  }
124
124
  async onMsg(msg) {
@@ -5,6 +5,10 @@ const Core_1 = require("../Core/Core");
5
5
  const Log_1 = require("../Logic/Log");
6
6
  const CgMq_1 = require("./CgMq");
7
7
  class Remote {
8
+ _retmsg = null;
9
+ get retMsg() {
10
+ return this._retmsg;
11
+ }
8
12
  _cgmq = null;
9
13
  get cgmq() {
10
14
  return this._cgmq;
@@ -15,8 +19,15 @@ class Remote {
15
19
  this._cgmq = cgmq;
16
20
  }
17
21
  async call(func_name, ...args) {
18
- let jsonData = await this._cgmq.callRemote(this._to_identity, func_name, ...args);
19
- return jsonData;
22
+ this._retmsg = await this._cgmq.callRemote(this._to_identity, func_name, ...args);
23
+ if (!this._retmsg.data) {
24
+ return;
25
+ }
26
+ let datas = this._retmsg.data;
27
+ if (datas.length == 1) {
28
+ return datas[0];
29
+ }
30
+ return datas;
20
31
  }
21
32
  }
22
33
  class RpcConfig extends CgMq_1.CgMqConfig {
@@ -6,6 +6,10 @@ export declare class IRpcClientWebSocket extends IClientWebSocket implements IRp
6
6
  id: number;
7
7
  des: string;
8
8
  }): any;
9
+ extendRetMsg(msg: RpcBaseMsg, errcode?: {
10
+ id: number;
11
+ des: string;
12
+ }): RpcBaseMsg;
9
13
  callRemote(msg: RpcBaseMsg): Promise<unknown>;
10
14
  receive_other_all(msg: RpcBaseMsg): void;
11
15
  protected _onMessage(msg: RpcBaseMsg): Promise<void>;
@@ -6,6 +6,10 @@ export declare class IRpcServerWebSocket extends IServerWebSocket implements IRp
6
6
  id: number;
7
7
  des: string;
8
8
  }): any;
9
+ extendRetMsg(msg: RpcBaseMsg, errcode?: {
10
+ id: number;
11
+ des: string;
12
+ }): RpcBaseMsg;
9
13
  callRemote(msg: RpcBaseMsg): Promise<unknown>;
10
14
  receive_other_all(msg: RpcBaseMsg): void;
11
15
  protected _onMessage(msg: RpcBaseMsg): Promise<void>;
@@ -45,7 +45,7 @@ export declare class CgMq {
45
45
  get cfg(): CgMqConfig;
46
46
  get identity(): string;
47
47
  init(cfg: CgMqConfig, onmsg?: (msg: CgMqRetMsg) => any): Promise<unknown>;
48
- callRemote(to_identity: string, func_name: string, ...args: any[]): Promise<unknown>;
48
+ callRemote(to_identity: string, func_name: string, ...args: any[]): Promise<CgMqRetMsg>;
49
49
  onMsg(msg: CgMqRetMsg): Promise<any>;
50
50
  }
51
51
  export {};
@@ -1,10 +1,12 @@
1
1
  import { CgMq, CgMqConfig, CgMqRetMsg } from "./CgMq";
2
2
  declare class Remote {
3
+ protected _retmsg: CgMqRetMsg;
4
+ get retMsg(): CgMqRetMsg;
3
5
  protected _cgmq: CgMq;
4
6
  get cgmq(): CgMq;
5
7
  protected _to_identity: string;
6
8
  constructor(identity: string, cgmq: CgMq);
7
- call(func_name: string, ...args: any[]): Promise<unknown>;
9
+ call(func_name: string, ...args: any[]): Promise<any | any[]>;
8
10
  }
9
11
  export declare class RpcConfig extends CgMqConfig {
10
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "6.9.466",
3
+ "version": "6.9.468",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",