SocketIO groups
2 answers
What you need to do is join () the socket into a group:
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
socket.join('justin bieber fans'); // put socket in a channel
socket.broadcast.to('justin bieber fans').emit('new fan'); // broadcast a message to a channel
io.sockets.in('rammstein fans').emit('new non-fan'); // to another channel
});
You need to do this for every socket that connects to you.
This is from the documentation at https://github.com/LearnBoost/socket.io (search for rooms).
+8
source to share