-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
39 lines (33 loc) · 1 KB
/
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
var express = require('express')
, app = express()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server)
, xPos = 0
, yPos = 0
app.use(express.static('scripts'))
app.get('/', function(req, res){
res.sendfile(__dirname + '/phone.html')
});
app.get('/display', function(req, res){
res.sendfile(__dirname + '/display.html')
});
io.sockets.on('connection', function(socket){
socket.emit('userName', '#'+Math.floor(Math.random()*16777215).toString(16));
socket.on('paint', function(paint){
socket.emit('paint', paint)
})
socket.on('data', function(data){
console.log("well atleast i'm here`");
io.sockets.emit('data2', data)
console.log("finished with that")
});
socket.on('xPos', function(value) {
xPos = value
console.log('setting x value: ' + value)
});
socket.on('yPos', function(value){
ypos = value;
console.log('setting y value: ' + value)
});
});
server.listen(3000);