aboutsummaryrefslogtreecommitdiff
path: root/socket.js
diff options
context:
space:
mode:
Diffstat (limited to 'socket.js')
-rw-r--r--socket.js24
1 files changed, 21 insertions, 3 deletions
diff --git a/socket.js b/socket.js
index b690151..d5ce72d 100644
--- a/socket.js
+++ b/socket.js
@@ -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
+ }
+ ]
+ }));
}
}