-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
43 lines (26 loc) · 858 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
32
33
34
35
36
37
38
39
40
41
console.log("server is working");
var express = require('express');
var app = express();
var server = app.listen(3000);
var io = require('socket.io')(server);
app.use(express.static('public'));
console.log("express server is working");
var socket = require('socket.io');
var io = socket(server);
io.sockets.on('connection', newConnection);
function newConnection(socket){
console.log('new connection: ' + socket.id);
// socket.on('mouse', mouseMsg);
// function mouseMsg(data){
// socket.broadcast.emit('mouseMoving', data);
// the line below will include posting to yourself back as well
//io.socket.emit('mouse', data);
// console.log(data);
// }
}
// io.on('connection', function(socket){
// console.log('a user connected');
// socket.on('disconnect', function(){
// console.log('user disconnected');
// });
// });