ee-core 4.1.3 → 4.1.4
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/LICENSE +21 -21
- package/README.md +65 -65
- package/app/application.d.ts +5 -5
- package/app/application.js +30 -30
- package/app/boot.d.ts +5 -5
- package/app/boot.js +80 -80
- package/app/dir.d.ts +1 -1
- package/app/dir.js +26 -26
- package/app/events.d.ts +14 -14
- package/app/events.js +55 -55
- package/app/index.d.ts +2 -2
- package/app/index.js +6 -6
- package/config/config_loader.d.ts +13 -13
- package/config/config_loader.js +65 -65
- package/config/default_config.d.ts +95 -95
- package/config/default_config.js +111 -111
- package/config/index.d.ts +28 -28
- package/config/index.js +24 -24
- package/const/channel.d.ts +16 -16
- package/const/channel.js +27 -27
- package/controller/controller_loader.d.ts +9 -9
- package/controller/controller_loader.js +77 -77
- package/controller/index.d.ts +2 -2
- package/controller/index.js +24 -24
- package/core/index.d.ts +2 -2
- package/core/index.js +11 -11
- package/core/loader/file_loader.d.ts +66 -66
- package/core/loader/file_loader.js +211 -211
- package/core/utils/index.d.ts +12 -12
- package/core/utils/index.js +83 -83
- package/core/utils/timing.d.ts +22 -22
- package/core/utils/timing.js +78 -78
- package/cross/cross.d.ts +19 -19
- package/cross/cross.js +151 -151
- package/cross/crossProcess.d.ts +29 -29
- package/cross/crossProcess.js +172 -172
- package/cross/index.d.ts +2 -2
- package/cross/index.js +8 -8
- package/electron/app/index.d.ts +5 -5
- package/electron/app/index.js +48 -48
- package/electron/index.d.ts +3 -3
- package/electron/index.js +15 -15
- package/electron/window/index.d.ts +6 -6
- package/electron/window/index.js +268 -268
- package/exception/index.d.ts +9 -9
- package/exception/index.js +100 -100
- package/html/boot.html +98 -98
- package/html/cross-failure.html +28 -28
- package/html/failure.html +28 -28
- package/html/index.d.ts +1 -1
- package/html/index.js +10 -10
- package/index.d.ts +2 -2
- package/index.js +6 -6
- package/jobs/child/app.d.ts +1 -1
- package/jobs/child/app.js +69 -69
- package/jobs/child/index.d.ts +13 -13
- package/jobs/child/index.js +85 -85
- package/jobs/child/jobProcess.d.ts +16 -16
- package/jobs/child/jobProcess.js +133 -133
- package/jobs/child-pool/index.d.ts +26 -26
- package/jobs/child-pool/index.js +190 -190
- package/jobs/index.d.ts +3 -3
- package/jobs/index.js +6 -6
- package/jobs/load-balancer/algorithm/index.d.ts +4 -4
- package/jobs/load-balancer/algorithm/index.js +11 -11
- package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -2
- package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
- package/jobs/load-balancer/algorithm/polling.d.ts +2 -2
- package/jobs/load-balancer/algorithm/polling.js +11 -11
- package/jobs/load-balancer/algorithm/random.d.ts +2 -2
- package/jobs/load-balancer/algorithm/random.js +9 -9
- package/jobs/load-balancer/algorithm/specify.d.ts +2 -2
- package/jobs/load-balancer/algorithm/specify.js +14 -14
- package/jobs/load-balancer/algorithm/weights.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weights.js +21 -21
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
- package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
- package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
- package/jobs/load-balancer/consts.d.ts +8 -8
- package/jobs/load-balancer/consts.js +9 -9
- package/jobs/load-balancer/index.d.ts +96 -96
- package/jobs/load-balancer/index.js +201 -201
- package/jobs/load-balancer/scheduler.d.ts +16 -16
- package/jobs/load-balancer/scheduler.js +31 -31
- package/loader/index.d.ts +9 -9
- package/loader/index.js +99 -98
- package/log/index.d.ts +5 -5
- package/log/index.js +85 -85
- package/log/logger.d.ts +1 -1
- package/log/logger.js +94 -94
- package/message/childMessage.d.ts +10 -10
- package/message/childMessage.js +43 -43
- package/message/index.d.ts +3 -3
- package/message/index.js +9 -9
- package/package.json +42 -42
- package/ps/index.d.ts +39 -39
- package/ps/index.js +294 -294
- package/socket/httpServer.d.ts +8 -8
- package/socket/httpServer.js +199 -199
- package/socket/index.d.ts +10 -10
- package/socket/index.js +64 -64
- package/socket/ipcServer.d.ts +9 -9
- package/socket/ipcServer.js +105 -105
- package/socket/socketServer.d.ts +10 -10
- package/socket/socketServer.js +81 -81
- package/storage/index.d.ts +4 -4
- package/storage/index.js +6 -6
- package/storage/sqliteStorage.d.ts +16 -16
- package/storage/sqliteStorage.js +123 -123
- package/tsconfig.json +13 -13
- package/utils/extend.d.ts +2 -2
- package/utils/extend.js +77 -77
- package/utils/helper.d.ts +14 -14
- package/utils/helper.js +206 -206
- package/utils/index.d.ts +10 -10
- package/utils/index.js +167 -167
- package/utils/ip.d.ts +2 -2
- package/utils/ip.js +221 -221
- package/utils/is.d.ts +14 -14
- package/utils/is.js +111 -111
- package/utils/json.d.ts +5 -5
- package/utils/json.js +79 -79
- package/utils/pargv.d.ts +3 -3
- package/utils/pargv.js +267 -267
- package/utils/port/index.d.ts +1 -1
- package/utils/port/index.js +125 -125
- package/utils/wrap.d.ts +4 -4
- package/utils/wrap.js +40 -40
package/socket/ipcServer.js
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const debug = require('debug')('ee-core:socket:ipcServer');
|
|
4
|
-
const is = require('is-type-of');
|
|
5
|
-
const { ipcMain } = require('electron');
|
|
6
|
-
const { coreLogger } = require('../log');
|
|
7
|
-
const { getController } = require('../controller');
|
|
8
|
-
const { EXPORTS } = require('../core/loader/file_loader');
|
|
9
|
-
const { getConfig } = require('../config');
|
|
10
|
-
|
|
11
|
-
class IpcServer {
|
|
12
|
-
constructor () {
|
|
13
|
-
const { mainServer } = getConfig();
|
|
14
|
-
this.channelSeparator = mainServer.channelSeparator;
|
|
15
|
-
this.directory = 'controller';
|
|
16
|
-
this.init();
|
|
17
|
-
}
|
|
18
|
-
init() {
|
|
19
|
-
const controller = getController();
|
|
20
|
-
this.loop(controller, this.directory);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
loop(obj, pathname) {
|
|
24
|
-
const keys = Object.keys(obj);
|
|
25
|
-
// debug("[loop] keys: %j", keys);
|
|
26
|
-
for (const key of keys) {
|
|
27
|
-
if (key === 'constructor') {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
let subObj = obj[key];
|
|
31
|
-
let propertyChain = pathname + '.' + key;
|
|
32
|
-
if (subObj && subObj[EXPORTS] === true) {
|
|
33
|
-
this.register(subObj, propertyChain);
|
|
34
|
-
} else if (typeof subObj === 'object') {
|
|
35
|
-
// 如果子对象依然是对象,则递归调用继续判断
|
|
36
|
-
this.loop(subObj, propertyChain);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
register(exportObj, propertyChain) {
|
|
42
|
-
const controller = getController();
|
|
43
|
-
const keys = Object.keys(exportObj);
|
|
44
|
-
for (const key of keys) {
|
|
45
|
-
// Supports two types of routing separators
|
|
46
|
-
// channel: controller.file.function | controller/file/function
|
|
47
|
-
const tmpChannel = `${propertyChain}.${key}`;
|
|
48
|
-
const channel = tmpChannel.split('.').join(this.channelSeparator);
|
|
49
|
-
debug('[register] channel %s', channel);
|
|
50
|
-
|
|
51
|
-
// send/on model
|
|
52
|
-
ipcMain.on(channel, async (event, params) => {
|
|
53
|
-
try {
|
|
54
|
-
const fn = this.findFn(controller, channel);
|
|
55
|
-
const result = await fn.call(controller, params, event);
|
|
56
|
-
|
|
57
|
-
event.returnValue = result;
|
|
58
|
-
event.reply(`${channel}`, result);
|
|
59
|
-
} catch(e) {
|
|
60
|
-
coreLogger.error('[ee-core] [socket/IpcServer] send/on throw error:', e);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// invoke/handle model
|
|
65
|
-
ipcMain.handle(channel, async (event, params) => {
|
|
66
|
-
try {
|
|
67
|
-
const fn = this.findFn(controller, channel);
|
|
68
|
-
const result = await fn.call(controller, params, event);
|
|
69
|
-
|
|
70
|
-
return result;
|
|
71
|
-
} catch(e) {
|
|
72
|
-
coreLogger.error('[ee-core] [socket/IpcServer] invoke/handle throw error:', e);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
findFn (controller, c) {
|
|
79
|
-
try {
|
|
80
|
-
// 找函数
|
|
81
|
-
const cmd = c;
|
|
82
|
-
let fn = null;
|
|
83
|
-
if (is.string(cmd)) {
|
|
84
|
-
const actions = cmd.split(this.channelSeparator);
|
|
85
|
-
debug('[findFn] channel %o', actions);
|
|
86
|
-
let obj = { controller };
|
|
87
|
-
actions.forEach(key => {
|
|
88
|
-
obj = obj[key];
|
|
89
|
-
if (!obj) throw new Error(`class or function '${key}' not exists`);
|
|
90
|
-
});
|
|
91
|
-
fn = obj;
|
|
92
|
-
}
|
|
93
|
-
if (!fn) throw new Error('function not exists');
|
|
94
|
-
|
|
95
|
-
return fn;
|
|
96
|
-
} catch (err) {
|
|
97
|
-
coreLogger.error('[ee-core] [socket/IpcServer] throw error:', err);
|
|
98
|
-
}
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
module.exports = {
|
|
105
|
-
IpcServer
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const debug = require('debug')('ee-core:socket:ipcServer');
|
|
4
|
+
const is = require('is-type-of');
|
|
5
|
+
const { ipcMain } = require('electron');
|
|
6
|
+
const { coreLogger } = require('../log');
|
|
7
|
+
const { getController } = require('../controller');
|
|
8
|
+
const { EXPORTS } = require('../core/loader/file_loader');
|
|
9
|
+
const { getConfig } = require('../config');
|
|
10
|
+
|
|
11
|
+
class IpcServer {
|
|
12
|
+
constructor () {
|
|
13
|
+
const { mainServer } = getConfig();
|
|
14
|
+
this.channelSeparator = mainServer.channelSeparator;
|
|
15
|
+
this.directory = 'controller';
|
|
16
|
+
this.init();
|
|
17
|
+
}
|
|
18
|
+
init() {
|
|
19
|
+
const controller = getController();
|
|
20
|
+
this.loop(controller, this.directory);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
loop(obj, pathname) {
|
|
24
|
+
const keys = Object.keys(obj);
|
|
25
|
+
// debug("[loop] keys: %j", keys);
|
|
26
|
+
for (const key of keys) {
|
|
27
|
+
if (key === 'constructor') {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
let subObj = obj[key];
|
|
31
|
+
let propertyChain = pathname + '.' + key;
|
|
32
|
+
if (subObj && subObj[EXPORTS] === true) {
|
|
33
|
+
this.register(subObj, propertyChain);
|
|
34
|
+
} else if (typeof subObj === 'object') {
|
|
35
|
+
// 如果子对象依然是对象,则递归调用继续判断
|
|
36
|
+
this.loop(subObj, propertyChain);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
register(exportObj, propertyChain) {
|
|
42
|
+
const controller = getController();
|
|
43
|
+
const keys = Object.keys(exportObj);
|
|
44
|
+
for (const key of keys) {
|
|
45
|
+
// Supports two types of routing separators
|
|
46
|
+
// channel: controller.file.function | controller/file/function
|
|
47
|
+
const tmpChannel = `${propertyChain}.${key}`;
|
|
48
|
+
const channel = tmpChannel.split('.').join(this.channelSeparator);
|
|
49
|
+
debug('[register] channel %s', channel);
|
|
50
|
+
|
|
51
|
+
// send/on model
|
|
52
|
+
ipcMain.on(channel, async (event, params) => {
|
|
53
|
+
try {
|
|
54
|
+
const fn = this.findFn(controller, channel);
|
|
55
|
+
const result = await fn.call(controller, params, event);
|
|
56
|
+
|
|
57
|
+
event.returnValue = result;
|
|
58
|
+
event.reply(`${channel}`, result);
|
|
59
|
+
} catch(e) {
|
|
60
|
+
coreLogger.error('[ee-core] [socket/IpcServer] send/on throw error:', e);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// invoke/handle model
|
|
65
|
+
ipcMain.handle(channel, async (event, params) => {
|
|
66
|
+
try {
|
|
67
|
+
const fn = this.findFn(controller, channel);
|
|
68
|
+
const result = await fn.call(controller, params, event);
|
|
69
|
+
|
|
70
|
+
return result;
|
|
71
|
+
} catch(e) {
|
|
72
|
+
coreLogger.error('[ee-core] [socket/IpcServer] invoke/handle throw error:', e);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
findFn (controller, c) {
|
|
79
|
+
try {
|
|
80
|
+
// 找函数
|
|
81
|
+
const cmd = c;
|
|
82
|
+
let fn = null;
|
|
83
|
+
if (is.string(cmd)) {
|
|
84
|
+
const actions = cmd.split(this.channelSeparator);
|
|
85
|
+
debug('[findFn] channel %o', actions);
|
|
86
|
+
let obj = { controller };
|
|
87
|
+
actions.forEach(key => {
|
|
88
|
+
obj = obj[key];
|
|
89
|
+
if (!obj) throw new Error(`class or function '${key}' not exists`);
|
|
90
|
+
});
|
|
91
|
+
fn = obj;
|
|
92
|
+
}
|
|
93
|
+
if (!fn) throw new Error('function not exists');
|
|
94
|
+
|
|
95
|
+
return fn;
|
|
96
|
+
} catch (err) {
|
|
97
|
+
coreLogger.error('[ee-core] [socket/IpcServer] throw error:', err);
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module.exports = {
|
|
105
|
+
IpcServer
|
|
106
106
|
};
|
package/socket/socketServer.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Server } from "socket.io";
|
|
2
|
-
import { DefaultEventsMap } from "socket.io/dist/typed-events";
|
|
3
|
-
export declare class SocketServer {
|
|
4
|
-
socket: import("socket.io").Socket<DefaultEventsMap, DefaultEventsMap, DefaultEventsMap, any>;
|
|
5
|
-
io: Server<DefaultEventsMap, DefaultEventsMap, DefaultEventsMap, any>;
|
|
6
|
-
config: any;
|
|
7
|
-
init(): Promise<void>;
|
|
8
|
-
connect(): void;
|
|
9
|
-
}
|
|
10
|
-
|
|
1
|
+
import { Server } from "socket.io";
|
|
2
|
+
import { DefaultEventsMap } from "socket.io/dist/typed-events";
|
|
3
|
+
export declare class SocketServer {
|
|
4
|
+
socket: import("socket.io").Socket<DefaultEventsMap, DefaultEventsMap, DefaultEventsMap, any>;
|
|
5
|
+
io: Server<DefaultEventsMap, DefaultEventsMap, DefaultEventsMap, any>;
|
|
6
|
+
config: any;
|
|
7
|
+
init(): Promise<void>;
|
|
8
|
+
connect(): void;
|
|
9
|
+
}
|
|
10
|
+
|
package/socket/socketServer.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const debug = require('debug')('ee-core:socket:socketServer');
|
|
4
|
-
const is = require('is-type-of');
|
|
5
|
-
const { Server } = require('socket.io');
|
|
6
|
-
const { coreLogger } = require('../log');
|
|
7
|
-
const { getConfig } = require('../config');
|
|
8
|
-
const { SocketIO } = require('../const/channel');
|
|
9
|
-
const { getController } = require('../controller');
|
|
10
|
-
const { getPort } = require('../utils/port');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* socket server
|
|
14
|
-
*/
|
|
15
|
-
class SocketServer {
|
|
16
|
-
constructor () {
|
|
17
|
-
const { socketServer, mainServer } = getConfig();
|
|
18
|
-
this.config = socketServer;
|
|
19
|
-
this.channelSeparator = mainServer.channelSeparator;
|
|
20
|
-
this.socket = undefined;
|
|
21
|
-
this.io = undefined;
|
|
22
|
-
this.init();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async init() {
|
|
26
|
-
if (this.config.enable == false) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const port = await getPort({port: parseInt(this.config.port)});
|
|
31
|
-
if (!port) {
|
|
32
|
-
throw new Error('[ee-core] [socket/socketServer] socekt port required, and must be a number !');
|
|
33
|
-
}
|
|
34
|
-
coreLogger.info('[ee-core] [socket/socketServer] port is:', port);
|
|
35
|
-
|
|
36
|
-
process.env.EE_SOCKET_PORT = port;
|
|
37
|
-
this.config.port = port;
|
|
38
|
-
this.io = new Server(port, this.config);
|
|
39
|
-
this.connect();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
connect () {
|
|
43
|
-
const controller = getController();
|
|
44
|
-
this.io.on('connection', (socket) => {
|
|
45
|
-
const channel = this.config.channel || SocketIO.partySoftware;
|
|
46
|
-
this.socket = socket;
|
|
47
|
-
socket.on(channel, async (message, callback) => {
|
|
48
|
-
coreLogger.info('[ee-core] [socket/socketServer] socket id:' + socket.id + ' message cmd: ' + message.cmd);
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
// find function
|
|
52
|
-
const cmd = message.cmd;
|
|
53
|
-
const args = message.args;
|
|
54
|
-
let fn = null;
|
|
55
|
-
debug('[socket] channel %s', cmd);
|
|
56
|
-
if (is.string(cmd)) {
|
|
57
|
-
const actions = cmd.split(this.channelSeparator);
|
|
58
|
-
debug('[findFn] channel %o', actions);
|
|
59
|
-
let obj = { controller };
|
|
60
|
-
actions.forEach(key => {
|
|
61
|
-
obj = obj[key];
|
|
62
|
-
if (!obj) throw new Error(`class or function '${key}' not exists`);
|
|
63
|
-
});
|
|
64
|
-
fn = obj;
|
|
65
|
-
}
|
|
66
|
-
if (!fn) throw new Error('function not exists');
|
|
67
|
-
|
|
68
|
-
const result = await fn.call(controller, args);
|
|
69
|
-
if (callback) {
|
|
70
|
-
callback(result);
|
|
71
|
-
}
|
|
72
|
-
} catch (err) {
|
|
73
|
-
coreLogger.error('[ee-core] [socket/socketServer] throw error:', err);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
module.exports = {
|
|
81
|
-
SocketServer,
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const debug = require('debug')('ee-core:socket:socketServer');
|
|
4
|
+
const is = require('is-type-of');
|
|
5
|
+
const { Server } = require('socket.io');
|
|
6
|
+
const { coreLogger } = require('../log');
|
|
7
|
+
const { getConfig } = require('../config');
|
|
8
|
+
const { SocketIO } = require('../const/channel');
|
|
9
|
+
const { getController } = require('../controller');
|
|
10
|
+
const { getPort } = require('../utils/port');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* socket server
|
|
14
|
+
*/
|
|
15
|
+
class SocketServer {
|
|
16
|
+
constructor () {
|
|
17
|
+
const { socketServer, mainServer } = getConfig();
|
|
18
|
+
this.config = socketServer;
|
|
19
|
+
this.channelSeparator = mainServer.channelSeparator;
|
|
20
|
+
this.socket = undefined;
|
|
21
|
+
this.io = undefined;
|
|
22
|
+
this.init();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async init() {
|
|
26
|
+
if (this.config.enable == false) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const port = await getPort({port: parseInt(this.config.port)});
|
|
31
|
+
if (!port) {
|
|
32
|
+
throw new Error('[ee-core] [socket/socketServer] socekt port required, and must be a number !');
|
|
33
|
+
}
|
|
34
|
+
coreLogger.info('[ee-core] [socket/socketServer] port is:', port);
|
|
35
|
+
|
|
36
|
+
process.env.EE_SOCKET_PORT = port;
|
|
37
|
+
this.config.port = port;
|
|
38
|
+
this.io = new Server(port, this.config);
|
|
39
|
+
this.connect();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
connect () {
|
|
43
|
+
const controller = getController();
|
|
44
|
+
this.io.on('connection', (socket) => {
|
|
45
|
+
const channel = this.config.channel || SocketIO.partySoftware;
|
|
46
|
+
this.socket = socket;
|
|
47
|
+
socket.on(channel, async (message, callback) => {
|
|
48
|
+
coreLogger.info('[ee-core] [socket/socketServer] socket id:' + socket.id + ' message cmd: ' + message.cmd);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
// find function
|
|
52
|
+
const cmd = message.cmd;
|
|
53
|
+
const args = message.args;
|
|
54
|
+
let fn = null;
|
|
55
|
+
debug('[socket] channel %s', cmd);
|
|
56
|
+
if (is.string(cmd)) {
|
|
57
|
+
const actions = cmd.split(this.channelSeparator);
|
|
58
|
+
debug('[findFn] channel %o', actions);
|
|
59
|
+
let obj = { controller };
|
|
60
|
+
actions.forEach(key => {
|
|
61
|
+
obj = obj[key];
|
|
62
|
+
if (!obj) throw new Error(`class or function '${key}' not exists`);
|
|
63
|
+
});
|
|
64
|
+
fn = obj;
|
|
65
|
+
}
|
|
66
|
+
if (!fn) throw new Error('function not exists');
|
|
67
|
+
|
|
68
|
+
const result = await fn.call(controller, args);
|
|
69
|
+
if (callback) {
|
|
70
|
+
callback(result);
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
coreLogger.error('[ee-core] [socket/socketServer] throw error:', err);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = {
|
|
81
|
+
SocketServer,
|
|
82
82
|
};
|
package/storage/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SqliteStorage } from "./sqliteStorage";
|
|
2
|
-
import { Database } from "better-sqlite3";
|
|
3
|
-
|
|
4
|
-
export { Database };
|
|
1
|
+
import { SqliteStorage } from "./sqliteStorage";
|
|
2
|
+
import { Database } from "better-sqlite3";
|
|
3
|
+
|
|
4
|
+
export { Database };
|
|
5
5
|
export { SqliteStorage };
|
package/storage/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { SqliteStorage } = require('./sqliteStorage');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
SqliteStorage
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { SqliteStorage } = require('./sqliteStorage');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
SqliteStorage
|
|
7
7
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import { Database } from "better-sqlite3";
|
|
3
|
-
export declare class SqliteStorage {
|
|
4
|
-
constructor(name: any, opt?: {});
|
|
5
|
-
name: string;
|
|
6
|
-
mode: string;
|
|
7
|
-
dbDir: string;
|
|
8
|
-
fileName: string;
|
|
9
|
-
db: Database;
|
|
10
|
-
_initDB(opt?: {}): any;
|
|
11
|
-
_formatFileName(name: string): string;
|
|
12
|
-
_createDatabaseDir(): string;
|
|
13
|
-
getMode(name: string): string;
|
|
14
|
-
getDbDir(): string;
|
|
15
|
-
getFilePath(): string;
|
|
16
|
-
}
|
|
1
|
+
|
|
2
|
+
import { Database } from "better-sqlite3";
|
|
3
|
+
export declare class SqliteStorage {
|
|
4
|
+
constructor(name: any, opt?: {});
|
|
5
|
+
name: string;
|
|
6
|
+
mode: string;
|
|
7
|
+
dbDir: string;
|
|
8
|
+
fileName: string;
|
|
9
|
+
db: Database;
|
|
10
|
+
_initDB(opt?: {}): any;
|
|
11
|
+
_formatFileName(name: string): string;
|
|
12
|
+
_createDatabaseDir(): string;
|
|
13
|
+
getMode(name: string): string;
|
|
14
|
+
getDbDir(): string;
|
|
15
|
+
getFilePath(): string;
|
|
16
|
+
}
|