Created
August 19, 2011 08:44
-
-
Save rogerdudler/1156354 to your computer and use it in GitHub Desktop.
Socket.io usage in Node.js
This file contains 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
// create an http server listening on port 8000 | |
var io = require('socket.io').listen(8000); | |
// listen on new connections | |
io.sockets.on('connection', function (socket) { | |
// listen on an event called "eventA" | |
socket.on('eventA', function(data) { | |
// send "eventA" to all clients, except the sender | |
io.sockets.emit('eventA', data); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment