2012-06-15 64 views

回答

2

在socket.io(1.3.x版)當前版本可以使用connect_error事件或reconnect_failed事件:

var socket = io(serverUrl); 
socket.on('connect_error', function() { 
    console.log('Connection failed'); 
}); 
socket.on('reconnect_failed', function() { 
    console.log('Reconnection failed'); 
}); 

參見:https://github.com/Automattic/socket.io-client#events

相關問題