-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFramework.js
42 lines (33 loc) · 987 Bytes
/
Framework.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const EventEmitter = require('events');
const StaticServer = require('static-server');
class Framework extends EventEmitter {
constructor () {
// Loads parent class
super();
// Starts webserver and websocket
this.server = new StaticServer({
name: 'Wolfe Labs Log Framework',
rootPath: __dirname + '/public',
port: 9000,
cors: '*',
});
// Boots!
this.server.start(() => {
this.socket = require('socket.io')(this.server._socket);
console.info('Web UI running at http://127.0.0.1:9000/');
});
}
loadedModules = {};
loadModule (modulePath, moduleName) {
const mod = require(modulePath);
// Initializes module
this.loadedModules[moduleName] = new mod(this);
}
getModule (moduleName) {
return this.loadedModules[moduleName];
}
pushDataToInterface (channelName, data) {
this.socket.emit(channelName, data);
}
}
module.exports = Framework;