Created
November 20, 2017 17:41
-
-
Save memish/88cb8cdf3618baa8fde4a81f22a4d9cb to your computer and use it in GitHub Desktop.
Server file for drawing app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('a user connected'); | |
socket.on('drawIn', function(clickX,clickY,dragging){//recieve message | |
console.log('message: ' + clickX,clickY,dragging); | |
io.emit('drawOut', clickX,clickY,dragging);//send message | |
}); | |
socket.on('disconnect', function(){ | |
console.log('user disconnected'); | |
}); | |
}); | |
http.listen(3000, function(){ | |
console.log('listening on *:3000'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment