I'm building a chat app on which, for every client connection, i need to set some attributes to every client instance using socket.io. When i save the attribute, i use:
client.set('name', name, function () {});
client.set('email', email, function () {});
....
and it runs fine. When i need to get all the client properties, i have not found a better way than this:
client.get("name",function(err,name) {
    client.get("email",function(err,email) {
       .......
    }
}
I need to nest all the "get" to asynchronously get data; but if i had 10 properties to get, do i need to nest all the 10 items? There must be a better way to do it, can anyone help me?
				
				I don't attach attributes to the socket.
 io.sockets.on('connection', function(socket) {
  var username = "xx";
  var email = "xx";
  socket.on('doX', function(data) {
    socket.emit('ackX', {username: username, email: email});
  });
});
I don't know if it's the best solution, but I have seen many examples like that.
EDIT : socket.io - getting more than one field for a socket? The correct answer may fit your needs