-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
39 lines (33 loc) · 1.13 KB
/
app.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
const NodeServer = require('./index');
const version = require('./package.json').version;
/**
* App example
*/
class AppExample {
/**
* Constructor
* @return {AppExample}
*/
constructor(){
this.http_server = new NodeServer.HttpServer({port: 80});
this.websocket_server_b = new NodeServer.WebSocketServer({port: 2222});
this.tcp_server = new NodeServer.TcpServer({port: 666});
this.udp_server = new NodeServer.UdpServer({port: 667});
// http routes
this.http_server.addRoute('GET', '/status', (req, res) => {
this.http_server.sendJson(res, {status:"Online"});
});
this.http_server.addRoute('GET', '/version', (req, res) => {
this.http_server.sendJson(res, {version});
});
// start
this.http_server.start();
this.websocket_server_a = new NodeServer.WebSocketServer({http_server: this.http_server});
this.websocket_server_a.start();
this.websocket_server_b.start();
this.tcp_server.start();
this.udp_server.start();
return this;
}
}
module.exports = new AppExample();