io.sockets.on('connection', function(socket) {
socket.object = socket.id;
socket.on('updateObject', function(data) {
// How to update socket.object here for all clients?
});
});
How to do it?
io.sockets.on('connection', function(socket) {
socket.object = socket.id;
socket.on('updateObject', function(data) {
// How to update socket.object here for all clients?
});
});
How to do it?
For the users using Socket.IO versions 1.0 or above this is the updated code for doing so.
Code to update socket object for all clients in a room
Please note that this function is not available anymore in socket.io versions higher then 1.0, it is recommended to keep a array of your socket.id's so you can iterate over them if need be. example by ynos1234
You can achieve this with the
forEach
function: