-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (25 loc) · 809 Bytes
/
server.js
File metadata and controls
40 lines (25 loc) · 809 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
37
38
console.log("socket.io is working");
var express = require('express');
var app = express();
var server = app.listen(3000);
app.use(express.static('public'));
console.log("My Socket 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');
// });
// });