내 nodejs 서버에서 "socket.io"를 사용하고 있습니다. 내 클래스/모듈 범위 (브라우저에서)에 등록 된 이벤트 함수를 실행하는 방법이 있습니까?socket.io (nodejs에 있음)의 이벤트 핸들러를 내 범위에 바인딩하는 방법은 무엇입니까?
...
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() {
// ...
}
...
불행히도 Chrome을 테스트 할 필요가 없으며 Firefox에서 작동하지 않습니다. 다른 방법이 있습니까? – koalabruder
그럼 Node.js에서 시도해보십시오 - 작동해야합니다. – Pointy
또한 Chrome을 사용해보세요. 좋은 브라우저이고 매우 빠릅니다. – Pointy