I have the following code when a user disconnects. I want to emit a signal with the room name and user name.
client.get('nickname', function(err, name) {
client.get('room', function(err2, room) {
io.sockets.in(room).emit('disconnect', name);
});
});
My question is, is there any way to avoid wrapping the .get calls like this? For my application, they are going to add up quickly. Can I get more than one value from one get() command? Or am I just handling this all wrong?
If you need to get a lot of values, take a look at a flow control library like async. For example, here’s how you might
getseveral values from the client in parallel: