node.js - How to get multiple socket attributes in socket.io? -
i'm building chat app on which, every client connection, need set attributes every client instance using socket.io. when save attribute, use:
client.set('name', name, function () {}); client.set('email', email, function () {}); ....   and runs fine. when need client properties, have not found better way this:
client.get("name",function(err,name) {     client.get("email",function(err,email) {        .......     } }   i need nest "get" asynchronously data; if had 10 properties get, need nest 10 items? there must better way it, can me?
i don't attach attributes 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 best solution, have seen many examples that.
edit : socket.io - getting more 1 field socket? correct answer may fit needs
Comments
Post a Comment