node.js & socket.io using client specific variables -


socket.on('connection', function(client){      var clientid = client.sessionid;   console.log('connection '+clientid);    var player = 0;   client.on('message',function(data){      handleclientdata(data,clientid);   });   client.on('disconnect',function(){     console.log('server has disconnected');   });   }); 

is variable "player" unique client? how can get/set variable function?

thanks.

it's variable local anonymous function runs when socket connection established. if want read function, either move global scope or pass function 1 of arguments. if want set function, either move global scope or pass function , read value when function returns.

if explain want use player for, there's clearer answer.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -