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.
This commit is contained in:
parent
2e5cae1b23
commit
9535539bb2
20
core/rfb.js
20
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();
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue