Always include ID marker in repeater protocol

This makes sure we're always following the protocol, and the caller
doesn't have to care about the details.
This commit is contained in:
Pierre Ossman 2017-10-14 13:02:40 +02:00
parent facf0b7027
commit ebf1c0f991
2 changed files with 5 additions and 5 deletions

View File

@ -732,7 +732,7 @@ RFB.prototype = {
} }
if (is_repeater) { if (is_repeater) {
var repeaterID = this._repeaterID; var repeaterID = "ID:" + this._repeaterID;
while (repeaterID.length < 250) { while (repeaterID.length < 250) {
repeaterID += "\0"; repeaterID += "\0";
} }

View File

@ -582,12 +582,12 @@ describe('Remote Frame Buffer Protocol Client', function() {
}); });
it('should interpret version 000.000 as a repeater', function () { it('should interpret version 000.000 as a repeater', function () {
client._repeaterID = '\x01\x02\x03\x04\x05'; client._repeaterID = '12345';
send_ver('000.000', client); send_ver('000.000', client);
expect(client._rfb_version).to.equal(0); expect(client._rfb_version).to.equal(0);
var sent_data = client._sock._websocket._get_sent_data(); var sent_data = client._sock._websocket._get_sent_data();
expect(new Uint8Array(sent_data.buffer, 0, 5)).to.array.equal(new Uint8Array([1, 2, 3, 4, 5])); expect(new Uint8Array(sent_data.buffer, 0, 9)).to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0]));
}); });
it('should interpret version 003.003 as version 3.3', function () { it('should interpret version 003.003 as version 3.3', function () {
@ -638,12 +638,12 @@ describe('Remote Frame Buffer Protocol Client', function() {
}); });
it('should handle two step repeater negotiation', function () { it('should handle two step repeater negotiation', function () {
client._repeaterID = '\x01\x02\x03\x04\x05'; client._repeaterID = '12345';
send_ver('000.000', client); send_ver('000.000', client);
expect(client._rfb_version).to.equal(0); expect(client._rfb_version).to.equal(0);
var sent_data = client._sock._websocket._get_sent_data(); var sent_data = client._sock._websocket._get_sent_data();
expect(new Uint8Array(sent_data.buffer, 0, 5)).to.array.equal(new Uint8Array([1, 2, 3, 4, 5])); expect(new Uint8Array(sent_data.buffer, 0, 9)).to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0]));
expect(sent_data).to.have.length(250); expect(sent_data).to.have.length(250);
send_ver('003.008', client); send_ver('003.008', client);