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+"");
}
在这个例子中,绑定解决了这个问题的可见性,但是客户端在 onSocketDataReceive 函数中是不可见的,有什么想法吗?如果我也尝试通过绑定传递客户端,那么这将变得不可见......