Callers should not need to modify this timeout.
/*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;
RFB.prototype = {
// ===== PROPERTIES =====
- disconnectTimeout: 3,
dragViewport: false,
_viewOnly: false,
this._disconnTimer = setTimeout(function () {
this._rfb_disconnect_reason = _("Disconnect timeout");
this._updateConnectionState('disconnected');
- }.bind(this), this._disconnectTimeout * 1000);
+ }.bind(this), DISCONNECT_TIMEOUT * 1000);
break;
}
},
- 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
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");
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');
});