我在我的 nodejs 服务器中使用“socket.io”。有没有办法在我的类/模块范围内(在浏览器中)运行注册的事件函数?
...
init: function() {
this.socket = new io.Socket('localhost:3000'); //connect to localhost presently
this.socket.on('connect', this.myConnect);
},
myConnect: function() {
// "this.socket" and "this.f" are unknown
// this.socket.send({});
// this.f();
},
f: function() {
// ...
}
...