Connect -> Disconnect -> Connect doesn't work
The following code doesn't work for me:
socket = io.connect('http://host.com:8081');socket.disconnect();socket = io.connect('http://host.com:8081');
This is a workaround I've found:
socket = io.connect('http://host.com:8081');socket.disconnect();delete io.sockets['http://host.com:8081'];io.j = [];socket = io.connect('http://host.com:8081');
another
var base = 'http://localhost:3000'
, channel = '/chat'
, url = base + channel;
var socket = io.connect(url);
// call socket.disconnect() won't disconnect, so:
io.sockets[base].disconnect();
// reconnect syntax.
delete io.sockets[base]; io.j =[];
socket = io.connect(url);
note: socket.io version - 0.9.0, platform: windows 7 home premium
출처 - https://github.com/LearnBoost/socket.io-client/issues/251
'Development > JavaScript' 카테고리의 다른 글
자바스크립트 이벤트 핸들링 (0) | 2012.12.27 |
---|---|
javascript random generate (0) | 2012.12.25 |
javascript - 클로저(Closure) (0) | 2012.12.01 |
javascript - Event 버블링 및 캡쳐링 해결방법 (0) | 2012.11.01 |
javascript - 세상에서 가장 오해가 많은 프로그래밍 언어 (0) | 2012.10.31 |