diff options
-rw-r--r-- | socket.js | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -49,7 +49,11 @@ class Socket extends retryws { for (var i=0; i<coords.length; i++){ coords[i] = {"minY":coords[i][0], "minX":coords[i][1], "maxY":coords[i][2], "maxX":coords[i][3]}; } - this.send(`{"fetchRectangles":${JSON.stringify(coords)},"kind":"fetch","v":"3"}`); + this.send( JSON.stringify({ + "fetchRectangles": coords, + "kind": "fetch", + "v": "3" + })); } this.write = function(chars){ //chars is an list of pairs [ pixel coordinate (y/x < 16), char ] @@ -63,11 +67,25 @@ class Socket extends retryws { chars[i].splice(4,0,0); chars[i].push(i); } - this.send(`{"edits":${JSON.stringify(chars)},"kind":"write"}`); + this.send( JSON.stringify({ + "edits": chars, + "kind": "write" + })); } this.cursor = function(coords){ //coords is just one pair of char coords; I think the api could handle more, but it's unnecessary for now. - this.send(`{"kind":"cursor","positions":[{"tileY":${Math.floor(coords[0]/8)},"tileX":${Math.floor(coords[1]/16)},"charY":${coords[0] % 8},"charX":${coords[1] % 16}}]}`); + this.send( JSON.stringify({ + "kind": "cursor", + "positions": + [ + { + "tileY": Math.floor(coords[0]/8), + "tileX": Math.floor(coords[1]/16), + "charY": coords[0] % 8, + "charX": coords[0] % 16 + } + ] + })); } } |