Here is a bit of non-working JavaScript code:
function clientEventsManager(io) {
this.connectedClients = 0;
this.createEventReceivers = function(io) {
io.sockets.on('connection', function(socket) {
this.connectedClients++;
//does not increase "connectedClients" of "clientEventsManager" function
}
}
createEventReceivers(io); //it is the only call to createEventReceivers()
}
var Manager = new clientEventsManager(io); //it is the only instanciation of clientEventsManager
My question is:
Is there a way to change clientEventsManager.connectedClients in clientEventsManager.createEventReceivers()?
EDIT: this post is a duplicate of this one, thank's for answering