Clean up special state handling for 'failed'
This commit is contained in:
parent
d5bbe50eb5
commit
159c50c009
25
core/rfb.js
25
core/rfb.js
|
@ -446,6 +446,8 @@
|
|||
return;
|
||||
}
|
||||
|
||||
this._rfb_state = state;
|
||||
|
||||
/*
|
||||
* These are disconnected states. A previous connect may
|
||||
* asynchronously cause a connection so make sure we are closed.
|
||||
|
@ -467,14 +469,7 @@
|
|||
Util.Warn(cmsg);
|
||||
}
|
||||
|
||||
if (oldstate === 'failed' && state === 'disconnected') {
|
||||
// do disconnect action, but stay in failed state
|
||||
this._rfb_state = 'failed';
|
||||
} else {
|
||||
this._rfb_state = state;
|
||||
}
|
||||
|
||||
if (this._disconnTimer && this._rfb_state !== 'disconnect') {
|
||||
if (this._disconnTimer && state !== 'disconnect') {
|
||||
Util.Debug("Clearing disconnect timer");
|
||||
clearTimeout(this._disconnTimer);
|
||||
this._disconnTimer = null;
|
||||
|
@ -512,12 +507,6 @@
|
|||
} else if (oldstate === 'init') {
|
||||
Util.Error("Error while initializing.");
|
||||
}
|
||||
|
||||
// Make sure we transition to disconnected
|
||||
setTimeout(function () {
|
||||
this._updateState('disconnected');
|
||||
}.bind(this), 50);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -525,10 +514,18 @@
|
|||
}
|
||||
|
||||
if (oldstate === 'failed' && state === 'disconnected') {
|
||||
// do disconnect action, but stay in failed state and
|
||||
// keep the previous status message
|
||||
this._rfb_state = 'failed';
|
||||
this._onUpdateState(this, state, oldstate);
|
||||
} else {
|
||||
this._onUpdateState(this, state, oldstate, statusMsg);
|
||||
}
|
||||
|
||||
// Make sure we transition to disconnected
|
||||
if (state === 'failed') {
|
||||
this._updateState('disconnected');
|
||||
}
|
||||
},
|
||||
|
||||
_fail: function (msg) {
|
||||
|
|
|
@ -677,7 +677,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
sinon.spy(client, '_fail');
|
||||
client._sock._websocket._receive_data(failure_data);
|
||||
|
||||
expect(client._fail).to.have.been.calledTwice;
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
expect(client._fail).to.have.been.calledWith('Security failure: whoops');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue