cgserver 8.0.2504 → 8.3.2546
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/Service/MongoAccountService.js +2 -7
- package/dist/lib/Framework/Service/MysqlAccountService.js +2 -7
- package/dist/lib/Framework/cgserver.js +24 -0
- package/dist/lib/Framework/index.js +3 -1
- package/dist/types/Framework/Service/MongoAccountService.d.ts +0 -1
- package/dist/types/Framework/Service/MysqlAccountService.d.ts +0 -1
- package/dist/types/Framework/cgserver.d.ts +3 -2
- package/dist/types/Framework/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,6 @@ const _error_1 = require("../Config/_error_");
|
|
|
5
5
|
const MongoBaseService_1 = require("../Database/MongoBaseService");
|
|
6
6
|
const MongoManager_1 = require("../Database/MongoManager");
|
|
7
7
|
const CacheTool_1 = require("../Logic/CacheTool");
|
|
8
|
-
const Log_1 = require("../Logic/Log");
|
|
9
8
|
const OpenSocial_1 = require("../ThirdParty/OpenSocial");
|
|
10
9
|
const QQTool_1 = require("../ThirdParty/QQTool");
|
|
11
10
|
const WechatTool_1 = require("../ThirdParty/WechatTool");
|
|
@@ -28,10 +27,6 @@ class MongoAccountModel extends MongoManager_1.MongoBaseModel {
|
|
|
28
27
|
}
|
|
29
28
|
exports.MongoAccountModel = MongoAccountModel;
|
|
30
29
|
class MongoAccountService extends MongoBaseService_1.MongoBaseService {
|
|
31
|
-
_getNewModel() {
|
|
32
|
-
Log_1.GLog.error("you should override this function:_getNewModel(){return T}!");
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
30
|
/**
|
|
36
31
|
* 注册新账号
|
|
37
32
|
* @param unionid
|
|
@@ -40,7 +35,7 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
|
|
|
40
35
|
* @param from
|
|
41
36
|
*/
|
|
42
37
|
async add(unionid, openid, ip, from) {
|
|
43
|
-
let account = this.
|
|
38
|
+
let account = new this._t_type();
|
|
44
39
|
switch (from) {
|
|
45
40
|
case ini_1.EAccountFrom.OpenSocial:
|
|
46
41
|
case ini_1.EAccountFrom.WeChat:
|
|
@@ -310,7 +305,7 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
|
|
|
310
305
|
async register(type, key, password, ip, extra) {
|
|
311
306
|
let rs = { user: null, errcode: null };
|
|
312
307
|
extra = extra || {};
|
|
313
|
-
let am = this.
|
|
308
|
+
let am = new this._t_type();
|
|
314
309
|
switch (type) {
|
|
315
310
|
case ini_1.EAccountFrom.Phone:
|
|
316
311
|
{
|
|
@@ -21,7 +21,6 @@ const NotNull_1 = require("../Database/Decorator/NotNull");
|
|
|
21
21
|
const Type_1 = require("../Database/Decorator/Type");
|
|
22
22
|
const AutoIncrement_1 = require("../Database/Decorator/AutoIncrement");
|
|
23
23
|
const ini_1 = require("./ini");
|
|
24
|
-
const Log_1 = require("../Logic/Log");
|
|
25
24
|
let MysqlAccountModel = class MysqlAccountModel extends MysqlBaseService_1.BaseModel {
|
|
26
25
|
id = -1;
|
|
27
26
|
phone = "";
|
|
@@ -103,10 +102,6 @@ MysqlAccountModel = __decorate([
|
|
|
103
102
|
exports.MysqlAccountModel = MysqlAccountModel;
|
|
104
103
|
//暂时不实例化,方便重写
|
|
105
104
|
class MysqlAccountService extends MysqlBaseService_1.MysqlBaseService {
|
|
106
|
-
_getNewModel() {
|
|
107
|
-
Log_1.GLog.error("you should override this function:_getNewModel(){return T}!");
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
105
|
/**
|
|
111
106
|
* 注册新账号
|
|
112
107
|
* @param unionid
|
|
@@ -115,7 +110,7 @@ class MysqlAccountService extends MysqlBaseService_1.MysqlBaseService {
|
|
|
115
110
|
* @param from
|
|
116
111
|
*/
|
|
117
112
|
async add(unionid, openid, ip, from) {
|
|
118
|
-
let account = this.
|
|
113
|
+
let account = new this._t_type();
|
|
119
114
|
switch (from) {
|
|
120
115
|
case ini_1.EAccountFrom.OpenSocial:
|
|
121
116
|
case ini_1.EAccountFrom.WeChat:
|
|
@@ -379,7 +374,7 @@ class MysqlAccountService extends MysqlBaseService_1.MysqlBaseService {
|
|
|
379
374
|
async register(type, key, password, ip, extra) {
|
|
380
375
|
let rs = { user: null, errcode: null };
|
|
381
376
|
extra = extra || {};
|
|
382
|
-
let am = this.
|
|
377
|
+
let am = new this._t_type();
|
|
383
378
|
switch (type) {
|
|
384
379
|
case ini_1.EAccountFrom.Phone:
|
|
385
380
|
{
|
|
@@ -24,6 +24,12 @@ class CgServer {
|
|
|
24
24
|
}
|
|
25
25
|
init() {
|
|
26
26
|
process.on("uncaughtException", this.onUnCaughtException.bind(this));
|
|
27
|
+
process.on("exit", this.onExit.bind(this));
|
|
28
|
+
//ctrl+c
|
|
29
|
+
process.on("SIGINT", this.onExit.bind(this));
|
|
30
|
+
//kill pid
|
|
31
|
+
process.on("SIGUSR1", this.onExit.bind(this));
|
|
32
|
+
process.on("SIGUSR2", this.onExit.bind(this));
|
|
27
33
|
process.env.TZ = "Asia/Shanghai";
|
|
28
34
|
EventTool_1.GEventTool.on("socket_server_init_done", this.onStart.bind(this));
|
|
29
35
|
EventTool_1.GEventTool.on("web_server_init_done", this.onStart.bind(this));
|
|
@@ -58,6 +64,20 @@ class CgServer {
|
|
|
58
64
|
Core_1.core.safeCall(events[i]);
|
|
59
65
|
}
|
|
60
66
|
}
|
|
67
|
+
async onExit() {
|
|
68
|
+
let events = this._events["exit"] || [];
|
|
69
|
+
let exit = true;
|
|
70
|
+
for (let i = 0; i < events.length; ++i) {
|
|
71
|
+
//只要有一个函数返回true,就不退出
|
|
72
|
+
let ret = await Core_1.core.safeCall(events[i]);
|
|
73
|
+
if (ret === true) {
|
|
74
|
+
exit = false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (exit) {
|
|
78
|
+
process.exit(0);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
61
81
|
addListener(event, func) {
|
|
62
82
|
this._events[event] = this._events[event] || [];
|
|
63
83
|
this._events[event].push(func);
|
|
@@ -76,6 +96,10 @@ class CgServer {
|
|
|
76
96
|
}
|
|
77
97
|
onUnCaughtException(e) {
|
|
78
98
|
Log_1.GLog.error(e.stack);
|
|
99
|
+
let events = this._events["uncaughtexception"] || [];
|
|
100
|
+
for (let i = 0; i < events.length; ++i) {
|
|
101
|
+
Core_1.core.safeCall(events[i]);
|
|
102
|
+
}
|
|
79
103
|
}
|
|
80
104
|
addWebServer(server) {
|
|
81
105
|
this._webservers.push(server);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoCacheModel = exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.MongoAccountService = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.RedisManager = exports.GRedisMgr = exports.SqlReturns = exports.SqlReturn = exports.SqlResult = 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.IServerConfig = 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.SyncCallServer = exports.SyncCall = exports.IRpcClientWebSocket = exports.IRpcServerWebSocket = exports.CgMqConfig = exports.CgMq = exports.RpcConfig = exports.Rpc = exports.RpcBaseMsg = 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.MysqlBaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.GAlipayTool = exports.BaseMsg = exports.IWebSocket = exports.ISocketServer = exports.IClientWebSocket = exports.IServerWebSocket = exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.EProtoType = void 0;
|
|
4
|
+
exports.SyncCallServer = exports.SyncCall = exports.IRpcClientWebSocket = exports.IRpcServerWebSocket = exports.CgMqConfig = exports.CgMq = exports.RpcConfig = exports.Rpc = exports.RpcBaseMsg = 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.MysqlBaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.AlipayCallBack = exports.AlipayResult = exports.GAlipayTool = exports.BaseMsg = exports.IWebSocket = exports.ISocketServer = exports.IClientWebSocket = exports.IServerWebSocket = exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.EProtoType = 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");
|
|
@@ -110,6 +110,8 @@ Object.defineProperty(exports, "IWebSocket", { enumerable: true, get: function (
|
|
|
110
110
|
Object.defineProperty(exports, "BaseMsg", { enumerable: true, get: function () { return IWebSocket_1.BaseMsg; } });
|
|
111
111
|
var AlipayTool_1 = require("./ThirdParty/AlipayTool");
|
|
112
112
|
Object.defineProperty(exports, "GAlipayTool", { enumerable: true, get: function () { return AlipayTool_1.GAlipayTool; } });
|
|
113
|
+
Object.defineProperty(exports, "AlipayResult", { enumerable: true, get: function () { return AlipayTool_1.AlipayResult; } });
|
|
114
|
+
Object.defineProperty(exports, "AlipayCallBack", { enumerable: true, get: function () { return AlipayTool_1.AlipayCallBack; } });
|
|
113
115
|
var Alisms_1 = require("./ThirdParty/Alisms");
|
|
114
116
|
Object.defineProperty(exports, "GSmsTool", { enumerable: true, get: function () { return Alisms_1.GSmsTool; } });
|
|
115
117
|
var AppleTool_1 = require("./ThirdParty/AppleTool");
|
|
@@ -14,8 +14,9 @@ declare class CgServer {
|
|
|
14
14
|
init(): void;
|
|
15
15
|
protected _done: number;
|
|
16
16
|
onStart(): void;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
onExit(): Promise<void>;
|
|
18
|
+
addListener(event: "start" | "exit" | "uncaughtexception", func: () => void): void;
|
|
19
|
+
removeListener(event: "start" | "exit" | "uncaughtexception", func: () => void): boolean;
|
|
19
20
|
onUnCaughtException(e: any): void;
|
|
20
21
|
addWebServer(server: IWebServer): void;
|
|
21
22
|
addSocketServer(server: ISocketServer): void;
|
|
@@ -47,7 +47,7 @@ export { IServerWebSocket } from './SocketServer/IServerWebSocket';
|
|
|
47
47
|
export { IClientWebSocket } from './SocketServer/IClientWebSocket';
|
|
48
48
|
export { ISocketServer } from './SocketServer/ISocketServer';
|
|
49
49
|
export { IWebSocket, BaseMsg } from './SocketServer/IWebSocket';
|
|
50
|
-
export { GAlipayTool } from './ThirdParty/AlipayTool';
|
|
50
|
+
export { GAlipayTool, AlipayResult, AlipayCallBack } from './ThirdParty/AlipayTool';
|
|
51
51
|
export { GSmsTool } from './ThirdParty/Alisms';
|
|
52
52
|
export { GAppleTool } from './ThirdParty/AppleTool';
|
|
53
53
|
export { GEmailTool } from './ThirdParty/EmailTool';
|