Handle server-side disconnections
Don't handle socket-close events when connected as errors. You could for example, in the VNC session run 'vncconfig -disconnect'.
This commit is contained in:
parent
e48d1b254e
commit
b45905ab86
|
@ -233,11 +233,16 @@
|
|||
case 'connecting':
|
||||
this._fail('Failed to connect to server' + msg);
|
||||
break;
|
||||
case 'connected':
|
||||
// Handle disconnects that were initiated server-side
|
||||
this._updateConnectionState('disconnecting');
|
||||
this._updateConnectionState('disconnected');
|
||||
break;
|
||||
case 'disconnected':
|
||||
Util.Error("Received onclose while disconnected" + msg);
|
||||
break;
|
||||
default:
|
||||
this._fail("Server disconnected" + msg);
|
||||
this._fail("Unexpected server disconnect" + msg);
|
||||
break;
|
||||
}
|
||||
this._sock.off('close');
|
||||
|
|
|
@ -2112,10 +2112,10 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
expect(client._rfb_connection_state).to.equal('disconnected');
|
||||
});
|
||||
|
||||
it('should transition to failed if we get a close event from any non-"disconnection" state', function () {
|
||||
it('should fail if we get a close event while connecting', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
client.connect('host', 8675);
|
||||
client._rfb_connection_state = 'connected';
|
||||
client._rfb_connection_state = 'connecting';
|
||||
client._sock._websocket.close();
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue