-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
31 lines (29 loc) · 819 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
29
30
31
var app=require ('express')();
var http= require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req,res){
res.sendFile(__dirname+'/index.html');
})
io.on('connection',function(socket){
console.log('one user connected.' + socket.id);
/* socket.on('message', function(data){
socket.emit('message',{message:data});
console.log(data);
})
*/
socket.on('obj',function(data){
io.sockets.emit('obj',{
x:data.x,
y:data.y,
z:data.z
// console.log('data:'+data.x);
})
console.log(data.x*Math.PI/180,data.y*Math.PI/180,data.z*Math.PI/180 );
})
socket.on('disconnect',function(){
console.log('one user disconnected' + socket.id);
})
})
http.listen(process.env.PORT || 5000,function(){
console.log('server listening on some Port');
});