forked from gerad/lazeroids-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
28 lines (28 loc) · 870 Bytes
/
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
(function() {
var app, express, pub, socket;
express = require('express');
pub = __dirname + '/public';
app = express.createServer(express.compiler({
src: pub,
enable: ['sass']
}), express.staticProvider(pub), express.logger(), express.errorHandler({
dumpExceptions: true,
showStack: true
}));
app.get('/', function(req, res) {
return res.render('index.jade');
});
app.get('/lazeroids.js', function(req, res) {
return res.sendfile('lazeroids.js');
});
app.listen(process.env.PORT || 8000);
socket = require('socket.io').listen(app);
socket.on('connection', function(client) {
client.on('message', function(message) {
return socket.broadcast(message);
});
return client.on('disconnect', function() {
return client.broadcast(JSON.stringify([['disconnect', client.sessionId]]));
});
});
})();