What is "efficient way" to check if some room has connected clients or even exists?
socket.on('pm', function(data) {
data.from = socket.decoded_token._id;
var to = data.to;
if (_.isUndefined(io.sockets.adapter.rooms[to])) {
debug("user [%s] is not connected", to);
} else {
socket.to(to).emit('pm', message);
}
});
Is it efficient way to do it with multiple instances of socket.io and redis adapter? I wish something like this could be used:
socket.on('pm', function(data) {
data.from = socket.decoded_token._id;
var to = data.to;
socket.to(to).emit('pm', message, function(err){
//error callback, but callback aren't supported for broadcast messages
debug("user [%s] is not connected", to);
});
}
});