samedi 18 avril 2015

Changing global variable from Socket.io Callback

Client code:



var app = {
data: {
user: null
}
};

var client = {
connect: function () {
client.data.socket.on('connectCallback', function (obj) {
if (obj.userFound) {
app.data.user = obj.user;
return app.data.user;
}
});
/**
Other callbacks
**/
};
};


app.data.user is always null, I also tried a second function to change the variable. The obj returned by the server isn't null, I already checked that.


Aucun commentaire:

Enregistrer un commentaire