broadway: Use a binary protocol to send to the server

This makes the protocol easier to inspect over the wire and makes all
commands fixed-length.
This commit is contained in:
Jasper St. Pierre
2013-09-26 12:21:08 -04:00
parent eb1ab0dac2
commit 0d0ff40d2f
2 changed files with 46 additions and 53 deletions

View File

@ -656,9 +656,17 @@ function getSurfaceId(ev) {
function sendInput(cmd, args)
{
if (inputSocket != null) {
inputSocket.send(cmd + ([lastSerial, lastTimeStamp].concat(args)).join(","));
}
if (inputSocket == null)
return;
var fullArgs = [cmd.charCodeAt(0), lastSerial, lastTimeStamp].concat(args);
var buffer = new ArrayBuffer(fullArgs.length * 4);
var view = new DataView(buffer);
fullArgs.forEach(function(arg, i) {
view.setInt32(i*4, arg, false);
});
inputSocket.send(buffer);
}
function getPositionsFromAbsCoord(absX, absY, relativeId) {