this is the code I have in an index.html (client). Im wondering why the number is not being incremented. I expect on each time a socket connect I give it a unique name.
 var number = 0;
    socket.on("connect",function(){
         number = number+1;
        socket.emit("add user","user"+ number )
    })
but when i have this server
io.on("connection", function(socket){
    console.log("io.onconnection")
    socket.on("add user", function(data){ 
    console.log(data)
    })
});
on each connection i get logged user1, why isn't the second connection user2? thanks
 
    