aboutsummaryrefslogtreecommitdiff
path: root/ui/js
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-03-18 15:48:31 +0100
committerlonkaars <loek@pipeframe.xyz>2024-03-18 15:48:31 +0100
commitaf9a3231f3174fd04082b75eddb6a6c6d57654ef (patch)
treef63cb07388967720f49ad125f274a69dc5ccd61c /ui/js
parentc13e5adad9dbbc3ab45461099c65c16b5873c760 (diff)
more extensive readme + cleanup socket
Diffstat (limited to 'ui/js')
-rw-r--r--ui/js/socket.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/ui/js/socket.js b/ui/js/socket.js
index 46edb8d..bb739d5 100644
--- a/ui/js/socket.js
+++ b/ui/js/socket.js
@@ -1,9 +1,9 @@
import api from './api.js';
-var ws = new WebSocket('ws://localhost:8081/socket');
+var ws = new WebSocket('ws://localhost:8081/');
export default ws;
-ws.onmessage = ev => {
+ws.addEventListener("message", ev => {
// this will already throw an error if the message doesn't contain valid JSON
const msg = JSON.parse(ev.data);
@@ -15,5 +15,9 @@ ws.onmessage = ev => {
// run the appropriate message handler
api.msg.handle[msg.type](msg);
-};
+});
+
+ws.addEventListener("close", () => {
+ console.error("WebSocket closed!");
+});