this.startServer = function(socket) {
var client = new Client();
client.socket = socket;
clients.push(client);
// Handle incoming messages from clients.
socket.on('data', bind(this.onSocketDataReceive, this));
}
this.onSocketDataReceive = function(data) {
this.commandManager(client, data+"");
}
In this example binding solves the visibility of this, but client is not visible in onSocketDataReceive function, any ideas? if I try to pass client with bind as well, then this becomes invisible...