Reputation: 17610
In version 0.6 I used this method to send a message to specific group of clients. It will exclude the clients with the session IDs in the 'excludedClients' array and send to all clients who are not excluded.
var excludedClients = [sessionID1, sessionID2, sessionID3];
io.broadcast(msg, excludedClients);
Hope someone can give me a hand with this, there doesn't seem to be any solid documentation for Socket IO anywhere, only briefly explained examples on the github page.
Upvotes: 1
Views: 2135
Reputation: 159105
I believe so; check out the wiki page on 0.6 to 0.7 migration.
If your clients can be grouped logically, you can use rooms.
Rooms
Sometimes you want to put a bunch of sockets in one room, and send a message to them. You can leverage rooms by calling
join
on a socket, and then with the flagsto
andin
:io.sockets.on('connection', function (socket) { socket.join('a room'); socket.broadcast.to('a room').send('im here'); io.sockets.in('some other room').emit('hi'); });
Upvotes: 4