-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (28 loc) · 708 Bytes
/
server.js
File metadata and controls
36 lines (28 loc) · 708 Bytes
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
var app = require('express')()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server);
var port;
if (process.env.PROD)
{
port = 80;
}
else{
port=8080;
}
server.listen(port);
app.get('/:resource', function (req, res) {
res.sendfile(__dirname+'/web/'+req.params.resource);
});
app.get('/js/:resource', function (req, res) {
res.sendfile(__dirname+'/web/js/'+req.params.resource);
});
var id = 0;
io.set('log level', 1);
io.sockets.on('connection', function (socket) {
socket.on('getId', function (data){
socket.emit('id', id++);
});
socket.on('gyroData',function (data){
socket.broadcast.emit('gyroData', data);
});
});