-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
46 lines (33 loc) · 1.36 KB
/
server.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
43
44
45
46
// ================ DEPENDENCIES ================================
// Configs
require('./config/extension-methods');
var serverConfig = require('./config/server-config');
var ioConfig = require('./config/io-config');
// NPM modules
var protocol = {};
var protocolName = serverConfig.httpsOptions ? 'https' : 'http';
protocol = require(protocolName);
var socketIo = require('socket.io');
// Project modules
var httpHandler = require('./http/httpHandler');
var ioHandler = require('./socket/ioHandler');
var logger = require('./logging/logger');
// require('./socket/socket-server');
// ==============================================================
// ================ IMPLEMENTATION ==============================
if (serverConfig.preStartScript) {
require('child_process').exec(serverConfig.preStartScript);
}
var server;
if (serverConfig.httpsOptions) {
server = protocol.createServer(serverConfig.httpsOptions, httpHandler.handle);
} else {
// Grabing audio from browser won't work over http for the most of the browsers
server = protocol.createServer(httpHandler.handle);
}
server.listen(serverConfig.httpPort); // .listen(serverConfig.port, serverConfig.host);
var io = socketIo.listen(server);
// ioConfig.config(io);
ioHandler.handle(io);
logger.logServerAddress(protocolName, serverConfig.httpPort);
// ================================================================