Welcome aboard! We are happy you are here and wish you good net-raft!
// you must install npm install socket.io node-static
var http = require('http');
var app = http.createServer(MyHandler);
var io = require('socket.io').listen(app);
var port = 3000;
function MyHandler(request, response) {
request.addListener('end', function() {
files.serve(request, response);
});
}
io.sockets.on('connection', function (socket) {
socket.on('send:coords', function (data) {
socket.broadcast.emit('load:coords', data);
});
});
app.listen(port);
console.log('Listening to Port ' + port);
The most helpful NODEJS solutions
get user ipNODEJS Click to see more ... 7.5K 1.7K