diff options
author | Pierre Ossman <ossman@cendio.se> | 2016-09-22 10:12:26 +0200 |
---|---|---|
committer | Samuel Mannehed <samuel@cendio.se> | 2016-10-24 14:42:08 +0200 |
commit | 9535539bb2416797709e3f93997ea0cee37e4759 (patch) | |
tree | 0e1777b937ecaec66a42ba0ca7ad21e2e2786eca | |
parent | 2e5cae1b233a450117ca19feb032c98202fa1297 (diff) | |
download | novnc-9535539bb2416797709e3f93997ea0cee37e4759.tar.gz |
Process entire WebSocket message at once
setTimeout() causes too much delay to be useful. Also, we
already handle all rects in a message at once, so this shouldn't
be too much of a change.
-rw-r--r-- | core/rfb.js | 20 | ||||
-rw-r--r-- | tests/test.rfb.js | 6 |
2 files changed, 3 insertions, 23 deletions
diff --git a/core/rfb.js b/core/rfb.js index 7f8ae6d..a0136f3 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -81,7 +81,6 @@ this._keyboard = null; // Keyboard input handler object this._mouse = null; // Mouse input handler object this._disconnTimer = null; // disconnection timer - this._msgTimer = null; // queued handle_msg timer this._supportsFence = false; @@ -415,11 +414,6 @@ }, _cleanup: function () { - if (this._msgTimer) { - clearInterval(this._msgTimer); - this._msgTimer = null; - } - if (this._display && this._display.get_context()) { if (!this._view_only) { this._keyboard.ungrab(); } if (!this._view_only) { this._mouse.ungrab(); } @@ -573,19 +567,7 @@ Util.Error("Got data while disconnected"); break; case 'connected': - if (this._normal_msg() && this._sock.rQlen() > 0) { - // true means we can continue processing - // Give other events a chance to run - if (this._msgTimer === null) { - Util.Debug("More data to process, creating timer"); - this._msgTimer = setTimeout(function () { - this._msgTimer = null; - this._handle_message(); - }.bind(this), 0); - } else { - Util.Debug("More data to process, existing timer"); - } - } + while (this._normal_msg() && this._sock.rQlen() > 0); break; default: this._init_msg(); diff --git a/tests/test.rfb.js b/tests/test.rfb.js index 43633da..b8bc9d2 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -1274,7 +1274,7 @@ describe('Remote Frame Buffer Protocol Client', function() { client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 3])); expect(client._sock._websocket._get_sent_data()).to.have.length(0); - client._framebufferUpdate = function () { return true; }; // we magically have enough data + client._framebufferUpdate = function () { this._sock.rQskip8(); return true; }; // we magically have enough data // 247 should *not* be used as the message type here client._sock._websocket._receive_data(new Uint8Array([247])); expect(client._sock).to.have.sent(expected_msg._sQ); @@ -2080,14 +2080,12 @@ describe('Remote Frame Buffer Protocol Client', function() { expect(client._init_msg).to.have.been.calledOnce; }); - it('should split up the handling of muplitle normal messages across 10ms intervals', function () { + it('should process all normal messages directly', function () { client.connect('host', 8675); client._sock._websocket._open(); client._rfb_connection_state = 'connected'; client.set_onBell(sinon.spy()); client._sock._websocket._receive_data(new Uint8Array([0x02, 0x02])); - expect(client.get_onBell()).to.have.been.calledOnce; - this.clock.tick(20); expect(client.get_onBell()).to.have.been.calledTwice; }); |