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
33e1462999
commit
c716466f18
20
core/rfb.js
20
core/rfb.js
|
|
@ -79,7 +79,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;
|
||||
|
||||
|
|
@ -398,11 +397,6 @@
|
|||
},
|
||||
|
||||
_cleanupSocket: function (state) {
|
||||
if (this._msgTimer) {
|
||||
clearInterval(this._msgTimer);
|
||||
this._msgTimer = null;
|
||||
}
|
||||
|
||||
if (this._display && this._display.get_context()) {
|
||||
this._keyboard.ungrab();
|
||||
this._mouse.ungrab();
|
||||
|
|
@ -548,19 +542,7 @@
|
|||
Util.Error("Got data while disconnected");
|
||||
break;
|
||||
case 'normal':
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -1200,7 +1200,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);
|
||||
|
|
@ -2002,14 +2002,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_state = 'normal';
|
||||
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