diff --git a/core/rfb.js b/core/rfb.js index 882b52b5..39e02dd2 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -28,6 +28,9 @@ import { encodings, encodingName } from "./encodings.js"; /*jslint white: false, browser: true */ /*global window, Util, Display, Keyboard, Mouse, Websock, Websock_native, Base64, DES, KeyTable, Inflator, XtScancode */ +// How many seconds to wait for a disconnect to finish +var DISCONNECT_TIMEOUT = 3; + export default function RFB(target) { this._target = target; @@ -216,7 +219,6 @@ export default function RFB(target) { RFB.prototype = { // ===== PROPERTIES ===== - disconnectTimeout: 3, dragViewport: false, _viewOnly: false, @@ -548,7 +550,7 @@ RFB.prototype = { this._disconnTimer = setTimeout(function () { this._rfb_disconnect_reason = _("Disconnect timeout"); this._updateConnectionState('disconnected'); - }.bind(this), this._disconnectTimeout * 1000); + }.bind(this), DISCONNECT_TIMEOUT * 1000); break; } }, diff --git a/docs/API.md b/docs/API.md index 18e96068..7b6596b9 100644 --- a/docs/API.md +++ b/docs/API.md @@ -46,10 +46,6 @@ protocol stream. - Is a `boolean` indicating if the framebuffer is larger than the current canvas, i.e. it is being clipped. -`disconnectTimeout` - - Is a `long` indicating how many seconds to wait for a disconnect - request to complete. Is set to `3` by default. - `capabilities` *Read only* - Is an `Object` indicating which optional extensions are available on the server. Some methods may only be called if the corresponding diff --git a/tests/test.rfb.js b/tests/test.rfb.js index b945fe2e..abe48a3f 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -483,7 +483,7 @@ describe('Remote Frame Buffer Protocol Client', function() { sinon.spy(client, '_updateConnectionState'); client._sock._websocket.close = function () {}; // explicitly don't call onclose client._updateConnectionState('disconnecting'); - this.clock.tick(client.disconnectTimeout * 1000); + this.clock.tick(3 * 1000); expect(client._updateConnectionState).to.have.been.calledTwice; expect(client._rfb_disconnect_reason).to.not.equal(""); expect(client._rfb_connection_state).to.equal("disconnected"); @@ -491,9 +491,9 @@ describe('Remote Frame Buffer Protocol Client', function() { it('should not fail if Websock.onclose gets called within the disconnection timeout', function () { client._updateConnectionState('disconnecting'); - this.clock.tick(client.disconnectTimeout * 500); + this.clock.tick(3 * 1000 / 2); client._sock._websocket.close(); - this.clock.tick(client.disconnectTimeout * 500 + 1); + this.clock.tick(3 * 1000 / 2 + 1); expect(client._rfb_connection_state).to.equal('disconnected'); });