cgserver 6.5.6 → 6.5.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.
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ 6.5.8
2
+ 1、修改编译bug
3
+ 6.5.7
4
+ 1、debug标志又cgserver处命令行处理,默认为false
5
+ 6.5.7
6
+ 1、增加配置debug,是否是debug调试模式,主要区别于读取数据档,debug默认读取file_d文件,release默认读取file_r文件,如果不存在都会读取file文件
1
7
  6.5.6
2
8
  1、增加一点服务器事件,目前cgserver只支持start
3
9
  6.5.5
@@ -7,6 +7,10 @@ class Config {
7
7
  _suffix = "";
8
8
  _is_init = false;
9
9
  _file_name = "";
10
+ /**
11
+ * 是否是debug调试模式,主要区别于读取数据档,debug默认读取file_d文件,release默认读取file_r文件,如果不存在都会读取file文件
12
+ */
13
+ static debug = false;
10
14
  constructor(filename) {
11
15
  this._file_name = filename;
12
16
  }
@@ -14,6 +18,10 @@ class Config {
14
18
  if (this._is_init) {
15
19
  return false;
16
20
  }
21
+ this._suffix = "r";
22
+ if (Config.debug) {
23
+ this._suffix = "d";
24
+ }
17
25
  let path = "data/" + this._file_name + "_" + this._suffix + ".json";
18
26
  path = path.toLowerCase();
19
27
  if (!fs.existsSync(path)) {
@@ -36,7 +36,9 @@ class WebServerConfig {
36
36
  exports.WebServerConfig = WebServerConfig;
37
37
  exports.GFCfg = null;
38
38
  class FrameworkConfig extends ServerConfig_1.ServerConfig {
39
- //-1不输出到console,0,仅错误信息输出到console,1,都输出到console
39
+ /*
40
+ *-1不输出到console,0,仅错误信息输出到console,1,都输出到console
41
+ */
40
42
  console_level = 0;
41
43
  log = {
42
44
  appenders: {
@@ -111,6 +113,9 @@ class FrameworkConfig extends ServerConfig_1.ServerConfig {
111
113
  },
112
114
  }
113
115
  };
116
+ /**
117
+ * 控制网络消息的
118
+ */
114
119
  debug_msg = false;
115
120
  local_host = "127.0.0.1";
116
121
  internet_host = "127.0.0.1";
@@ -95,15 +95,15 @@ class Log {
95
95
  _isNumber(param) {
96
96
  return typeof (param) === "number";
97
97
  }
98
- _format = function (src, formatStr) {
99
- if (this.isString(src)) {
98
+ _format(src, formatStr) {
99
+ if (this._isString(src)) {
100
100
  let args = Array.prototype.slice.call(arguments, 1);
101
101
  return src.replace(/\{(\d+)\}/g, function (m, i) {
102
102
  return args[i];
103
103
  });
104
104
  }
105
105
  else {
106
- if (this.isNumber(src)) {
106
+ if (this._isNumber(src)) {
107
107
  src = new Date(src);
108
108
  }
109
109
  let str = formatStr;
@@ -130,6 +130,6 @@ class Log {
130
130
  str = str.replace(/s|S/g, sec);
131
131
  return str;
132
132
  }
133
- };
133
+ }
134
134
  }
135
135
  exports.GLog = new Log();
@@ -4,8 +4,13 @@ exports.GCgServer = void 0;
4
4
  const Log_1 = require("./Logic/Log");
5
5
  const EventTool_1 = require("./Logic/EventTool");
6
6
  const Core_1 = require("./Core/Core");
7
+ const Config_1 = require("./Config/Config");
7
8
  class CgServer {
8
9
  _events = {};
10
+ _debug = false;
11
+ get debug() {
12
+ return this._debug;
13
+ }
9
14
  constructor() {
10
15
  this.init();
11
16
  }
@@ -13,6 +18,14 @@ class CgServer {
13
18
  process.on("uncaughtException", this.onUnCaughtException.bind(this));
14
19
  process.env.TZ = "Asia/Shanghai";
15
20
  EventTool_1.GEventTool.on("socket_server_init_done", this.onStart.bind(this));
21
+ let argv = process.argv || [];
22
+ for (let i = 0; i < argv.length; ++i) {
23
+ let arg = argv[i].toLowerCase();
24
+ if (arg == "-d" || arg == "-debug") {
25
+ Config_1.Config.debug = true;
26
+ this._debug = true;
27
+ }
28
+ }
16
29
  }
17
30
  onStart() {
18
31
  let events = this._events["start"] || [];
@@ -20,11 +33,11 @@ class CgServer {
20
33
  Core_1.core.safeCall(events[i]);
21
34
  }
22
35
  }
23
- addListenser(event, func) {
36
+ addListener(event, func) {
24
37
  this._events[event] = this._events[event] || [];
25
38
  this._events[event].push(func);
26
39
  }
27
- removeListenser(event, func) {
40
+ removeListener(event, func) {
28
41
  let events = this._events[event];
29
42
  if (!events) {
30
43
  return false;
@@ -2,6 +2,10 @@ export declare class Config {
2
2
  protected _suffix: string;
3
3
  protected _is_init: boolean;
4
4
  protected _file_name: string;
5
+ /**
6
+ * 是否是debug调试模式,主要区别于读取数据档,debug默认读取file_d文件,release默认读取file_r文件,如果不存在都会读取file文件
7
+ */
8
+ static debug: boolean;
5
9
  constructor(filename: any);
6
10
  init(): boolean;
7
11
  }
@@ -116,6 +116,9 @@ export declare class FrameworkConfig extends ServerConfig {
116
116
  };
117
117
  };
118
118
  };
119
+ /**
120
+ * 控制网络消息的
121
+ */
119
122
  debug_msg: boolean;
120
123
  local_host: string;
121
124
  internet_host: string;
@@ -114,7 +114,7 @@ declare class MongoManager {
114
114
  id: number;
115
115
  des: string;
116
116
  };
117
- rs: mongo.UpdateResult | mongo.Document;
117
+ rs: mongo.Document | mongo.UpdateResult;
118
118
  }>;
119
119
  createIndex(collection: string, index: any, callback?: mongo.CreateIndexesOptions): Promise<{
120
120
  errcode: {
@@ -20,6 +20,6 @@ declare class Log {
20
20
  protected _isObject(param: any): boolean;
21
21
  protected _isString(param: any): boolean;
22
22
  protected _isNumber(param: any): boolean;
23
- protected _format: (src: any, formatStr: any) => any;
23
+ protected _format(src: any, formatStr: any): any;
24
24
  }
25
25
  export {};
@@ -2,11 +2,13 @@ declare class CgServer {
2
2
  protected _events: {
3
3
  [name: string]: Function[];
4
4
  };
5
+ protected _debug: boolean;
6
+ get debug(): boolean;
5
7
  constructor();
6
8
  init(): void;
7
9
  onStart(): void;
8
- addListenser(event: "start", func: () => void): void;
9
- removeListenser(event: "start", func: () => void): boolean;
10
+ addListener(event: "start", func: () => void): void;
11
+ removeListener(event: "start", func: () => void): boolean;
10
12
  onUnCaughtException(e: any): void;
11
13
  }
12
14
  export declare let GCgServer: CgServer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "6.5.6",
3
+ "version": "6.5.9",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",