aboutsummaryrefslogtreecommitdiff
path: root/socket.js
diff options
context:
space:
mode:
authorHolden Rohrer <holden.rohrer@gmail.com>2019-12-17 21:47:05 -0500
committerHolden Rohrer <holden.rohrer@gmail.com>2019-12-17 21:47:05 -0500
commit345b07af1434abefbb1c037c6d407a6671f8ae75 (patch)
tree71e2b6b55c368e8ba819cc10a69d1259b8efcfc6 /socket.js
parentd362969d840db3b2e157655c1b2a6325fec2aacc (diff)
minor parse errors
Diffstat (limited to 'socket.js')
-rw-r--r--socket.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/socket.js b/socket.js
index 4a030f5..f5817d4 100644
--- a/socket.js
+++ b/socket.js
@@ -1,4 +1,6 @@
/* socket.js, a simple wrapper for a YWOT websocket connection */
+const ws = require('ws')
+const EventEmitter = require('events');
class retryws extends EventEmitter{ // a wrapper on ws that retries on failure
constructor(addr) {
@@ -38,7 +40,7 @@ class Socket extends retryws {
case 'fetch':
this.emit('fetch', message.tiles); break; // The response to a fetch request
}
- }
+ });
this.fetch = function(coords){ //coords is a list of quadruplets, each a min/max pair of y/x coordinate pairs which describes at most 1000 tiles
//Unchecked for speed
@@ -56,12 +58,14 @@ class Socket extends retryws {
chars[i].splice(4,0,0); //
chars[i].push(i);
}
- this.send(`{"edits":${JSON.stringify(chars)},"kind":"write"}`;
+ this.send(`{"edits":${JSON.stringify(chars)},"kind":"write"}`);
}
this.cursor = function(coords){ //coords is just one quadruplet analagous to fetch; I think the api could handle more, but it's unnecessary for now.
- this.send(`"kind":"cursor","positions":[${JSON.stringify(coords)}]}`;
+ this.send(`"kind":"cursor","positions":[${JSON.stringify(coords)}]}`);
}
}
}
+
+exports.Socket = Socket;