mirror of
https://github.com/novnc/noVNC.git
synced 2026-06-09 05:44:38 +00:00
Always flush socket after each message
Make sure our messages go away right away, rather than having to remember to call flush from the caller, or causing extra delays by waiting for the send timer. This should result in a more responsive system.
This commit is contained in:
@@ -67,7 +67,6 @@ var RFB;
|
||||
this._display = null; // Display object
|
||||
this._keyboard = null; // Keyboard input handler object
|
||||
this._mouse = null; // Mouse input handler object
|
||||
this._sendTimer = null; // Send Queue check timer
|
||||
this._disconnTimer = null; // disconnection timer
|
||||
this._msgTimer = null; // queued handle_msg timer
|
||||
|
||||
@@ -268,8 +267,6 @@ var RFB;
|
||||
RFB.messages.keyEvent(this._sock, XK_Delete, 0);
|
||||
RFB.messages.keyEvent(this._sock, XK_Alt_L, 0);
|
||||
RFB.messages.keyEvent(this._sock, XK_Control_L, 0);
|
||||
|
||||
this._sock.flush();
|
||||
},
|
||||
|
||||
xvpOp: function (ver, op) {
|
||||
@@ -303,14 +300,11 @@ var RFB;
|
||||
RFB.messages.keyEvent(this._sock, code, 1);
|
||||
RFB.messages.keyEvent(this._sock, code, 0);
|
||||
}
|
||||
|
||||
this._sock.flush();
|
||||
},
|
||||
|
||||
clipboardPasteFrom: function (text) {
|
||||
if (this._rfb_state !== 'normal') { return; }
|
||||
RFB.messages.clientCutText(this._sock, text);
|
||||
this._sock.flush();
|
||||
},
|
||||
|
||||
// Requests a change of remote desktop size. This message is an extension
|
||||
@@ -386,11 +380,6 @@ var RFB;
|
||||
},
|
||||
|
||||
_cleanupSocket: function (state) {
|
||||
if (this._sendTimer) {
|
||||
clearInterval(this._sendTimer);
|
||||
this._sendTimer = null;
|
||||
}
|
||||
|
||||
if (this._msgTimer) {
|
||||
clearInterval(this._msgTimer);
|
||||
this._msgTimer = null;
|
||||
@@ -564,7 +553,6 @@ var RFB;
|
||||
_handleKeyPress: function (keysym, down) {
|
||||
if (this._view_only) { return; } // View only, skip keyboard, events
|
||||
RFB.messages.keyEvent(this._sock, keysym, down);
|
||||
this._sock.flush();
|
||||
},
|
||||
|
||||
_handleMouseButton: function (x, y, down, bmask) {
|
||||
@@ -670,10 +658,6 @@ var RFB;
|
||||
this._rfb_version = this._rfb_max_version;
|
||||
}
|
||||
|
||||
// Send updates either at a rate of 1 update per 50ms, or
|
||||
// whatever slower rate the network can handle
|
||||
this._sendTimer = setInterval(this._sock.flush.bind(this._sock), 50);
|
||||
|
||||
var cversion = "00" + parseInt(this._rfb_version, 10) +
|
||||
".00" + ((this._rfb_version * 10) % 10);
|
||||
this._sock.send_string("RFB " + cversion + "\n");
|
||||
@@ -992,7 +976,6 @@ var RFB;
|
||||
|
||||
this._timing.fbu_rt_start = (new Date()).getTime();
|
||||
this._timing.pixels = 0;
|
||||
this._sock.flush();
|
||||
|
||||
if (this._encrypt) {
|
||||
this._updateState('normal', 'Connected (encrypted) to: ' + this._fb_name);
|
||||
@@ -1095,7 +1078,6 @@ var RFB;
|
||||
var ret = this._framebufferUpdate();
|
||||
if (ret) {
|
||||
RFB.messages.fbUpdateRequests(this._sock, this._display.getCleanDirtyReset(), this._fb_width, this._fb_height);
|
||||
this._sock.flush();
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -1285,6 +1267,7 @@ var RFB;
|
||||
buff[offset + 7] = keysym;
|
||||
|
||||
sock._sQlen += 8;
|
||||
sock.flush();
|
||||
},
|
||||
|
||||
pointerEvent: function (sock, x, y, mask) {
|
||||
@@ -1302,6 +1285,7 @@ var RFB;
|
||||
buff[offset + 5] = y;
|
||||
|
||||
sock._sQlen += 6;
|
||||
sock.flush();
|
||||
},
|
||||
|
||||
// TODO(directxman12): make this unicode compatible?
|
||||
@@ -1327,6 +1311,7 @@ var RFB;
|
||||
}
|
||||
|
||||
sock._sQlen += 8 + n;
|
||||
sock.flush();
|
||||
},
|
||||
|
||||
setDesktopSize: function (sock, width, height, id, flags) {
|
||||
@@ -1362,6 +1347,7 @@ var RFB;
|
||||
buff[offset + 23] = flags;
|
||||
|
||||
sock._sQlen += 24;
|
||||
sock.flush();
|
||||
},
|
||||
|
||||
pixelFormat: function (sock, bpp, depth, true_color) {
|
||||
@@ -1397,6 +1383,7 @@ var RFB;
|
||||
buff[offset + 19] = 0; // padding
|
||||
|
||||
sock._sQlen += 20;
|
||||
sock.flush();
|
||||
},
|
||||
|
||||
clientEncodings: function (sock, encodings, local_cursor, true_color) {
|
||||
@@ -1431,6 +1418,7 @@ var RFB;
|
||||
buff[offset + 3] = cnt;
|
||||
|
||||
sock._sQlen += j - offset;
|
||||
sock.flush();
|
||||
},
|
||||
|
||||
fbUpdateRequests: function (sock, cleanDirty, fb_width, fb_height) {
|
||||
@@ -1477,6 +1465,7 @@ var RFB;
|
||||
buff[offset + 9] = h & 0xFF;
|
||||
|
||||
sock._sQlen += 10;
|
||||
sock.flush();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user