rfb.js: avoid multiple b64 sequences per frame.
Only call encode_message when the WebSockets object is actually ready to send. Otherwise multiple base64 encode sequences can be encoded into the same WebSockets frame. This causes the C version of wsproxy to crash and the python version to ignore the subsequent base64 sequence(s). Thanks to Colin Dean (xvpsource.org) for finding this and helping track it down.
This commit is contained in:
parent
c7c0c8d441
commit
16d1493fce
@ -73,7 +73,7 @@ var that = {}, // Public API interface
|
|||||||
rQ = [], // Receive Queue
|
rQ = [], // Receive Queue
|
||||||
rQi = 0, // Receive Queue Index
|
rQi = 0, // Receive Queue Index
|
||||||
rQmax = 100000, // Max size before compacting
|
rQmax = 100000, // Max size before compacting
|
||||||
sQ = "", // Send Queue
|
sQ = [], // Send Queue
|
||||||
|
|
||||||
// Frame buffer update state
|
// Frame buffer update state
|
||||||
FBU = {
|
FBU = {
|
||||||
@ -319,7 +319,7 @@ init_vars = function() {
|
|||||||
/* Reset state */
|
/* Reset state */
|
||||||
rQ = [];
|
rQ = [];
|
||||||
rQi = 0;
|
rQi = 0;
|
||||||
sQ = "";
|
sQ = [];
|
||||||
FBU.rects = 0;
|
FBU.rects = 0;
|
||||||
FBU.subrects = 0; // RRE and HEXTILE
|
FBU.subrects = 0; // RRE and HEXTILE
|
||||||
FBU.lines = 0; // RAW
|
FBU.lines = 0; // RAW
|
||||||
@ -525,9 +525,9 @@ function fail(msg) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function encode_message(arr) {
|
function encode_message() {
|
||||||
/* base64 encode */
|
/* base64 encode */
|
||||||
sQ = sQ + Base64.encode(arr);
|
return Base64.encode(sQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
function decode_message(data) {
|
function decode_message(data) {
|
||||||
@ -605,12 +605,12 @@ recv_message = function(e) {
|
|||||||
// overridable for testing
|
// overridable for testing
|
||||||
send_array = function(arr) {
|
send_array = function(arr) {
|
||||||
//Util.Debug(">> send_array: " + arr);
|
//Util.Debug(">> send_array: " + arr);
|
||||||
encode_message(arr);
|
sQ = sQ.concat(arr);
|
||||||
if (ws.bufferedAmount === 0) {
|
if (ws.bufferedAmount === 0) {
|
||||||
//Util.Debug("arr: " + arr);
|
//Util.Debug("arr: " + arr);
|
||||||
//Util.Debug("sQ: " + sQ);
|
//Util.Debug("sQ: " + sQ);
|
||||||
ws.send(sQ);
|
ws.send(encode_message(sQ));
|
||||||
sQ = "";
|
sQ = [];
|
||||||
} else {
|
} else {
|
||||||
Util.Debug("Delaying send");
|
Util.Debug("Delaying send");
|
||||||
}
|
}
|
||||||
@ -723,8 +723,8 @@ init_msg = function() {
|
|||||||
// can handle.
|
// can handle.
|
||||||
if (ws.bufferedAmount === 0) {
|
if (ws.bufferedAmount === 0) {
|
||||||
if (sQ) {
|
if (sQ) {
|
||||||
ws.send(sQ);
|
ws.send(encode_message(sQ));
|
||||||
sQ = "";
|
sQ = [];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Util.Debug("Delaying send");
|
Util.Debug("Delaying send");
|
||||||
|
Loading…
Reference in New Issue
Block a user