Skip to content

Instantly share code, notes, and snippets.

@ramonvictor
Last active April 27, 2016 20:44
Show Gist options
  • Save ramonvictor/4696208b06f954782e9111043cefbe90 to your computer and use it in GitHub Desktop.
Save ramonvictor/4696208b06f954782e9111043cefbe90 to your computer and use it in GitHub Desktop.
// [require modules and do some express setup]
// ...and here is where the magic happens:
io.on('connection', function(socket) {
socket.on('room', function(room) {
socket.join(room);
});
socket.on('dispatch', function(data) {
socket.broadcast.to(data.room).emit('dispatch', data);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment