-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocket_prod.js
40 lines (32 loc) · 1.17 KB
/
socket_prod.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
/*
* @author Wan Zulsarhan
* Location : /var/www/cf-app/socket
* Description : Socket Server in production server
*/
var bodyParser = require('body-parser');
var express = require('express')
, http = require('http');
//make sure you keep this order
var app = express();
var server = http.createServer(app);
var io = require('socket.io').listen(server);
//app.use('/socket', express.static(path.join(__dirname, 'public')));
//app.use('/socket', require('./routes'));
app.use(express.static(__dirname + '/socket/res'));
app.use(bodyParser.urlencoded({extended: false}));
/// this is important
app.get('/socket', function (req, res, next) {
res.sendFile(__dirname + '/index.html');
});
app.get('/socket/socket-client', function (req, res, next) {
res.sendFile(__dirname + '/res/socket.io.js');
});
const { Port } = require('./config/socket-config');
server.listen(Port, function () {
console.log('listening on port ' + Port);
});
// ***************************************************************************** //
// CODE START HERE
var SocketServer = require('./server/socket/model/SocketServer.js');
var socketServer = new SocketServer(io);
socketServer.init();