Don't treat onerror as a close.

The close event will also fire so trying to fail the connection twice
is unhelpful and hiding status information.
This commit is contained in:
Joel Martin 2012-04-25 20:13:25 -05:00
parent c390011099
commit dcf1994d3e
1 changed files with 7 additions and 5 deletions

View File

@ -234,6 +234,7 @@ function constructor() {
}
});
ws.on('close', function(e) {
Util.Warn("WebSocket on-close event");
var msg = "";
if (e.code) {
msg = " (code: " + e.code;
@ -253,7 +254,8 @@ function constructor() {
}
});
ws.on('error', function(e) {
fail("WebSock reported an error");
Util.Warn("WebSocket on-error event");
//fail("WebSock reported an error");
});
@ -424,16 +426,16 @@ updateState = function(state, statusMsg) {
func = Util.Warn;
}
cmsg = typeof(statusMsg) !== 'undefined' ? (" Msg: " + statusMsg) : "";
func("New state '" + state + "', was '" + oldstate + "'." + cmsg);
if ((oldstate === 'failed') && (state === 'disconnected')) {
// Do disconnect action, but stay in failed state.
// Do disconnect action, but stay in failed state
rfb_state = 'failed';
} else {
rfb_state = state;
}
cmsg = typeof(statusMsg) !== 'undefined' ? (" Msg: " + statusMsg) : "";
func("New state '" + rfb_state + "', was '" + oldstate + "'." + cmsg);
if (connTimer && (rfb_state !== 'connect')) {
Util.Debug("Clearing connect timer");
clearInterval(connTimer);