aboutsummaryrefslogtreecommitdiff
path: root/ui/js/socket.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/js/socket.js')
-rw-r--r--ui/js/socket.js8
1 files changed, 3 insertions, 5 deletions
diff --git a/ui/js/socket.js b/ui/js/socket.js
index ec4fe53..0203b43 100644
--- a/ui/js/socket.js
+++ b/ui/js/socket.js
@@ -1,7 +1,5 @@
import api from './api.js';
-const msgTypeKey = "functie";
-
var ws = new WebSocket('ws://localhost:8081/');
export default ws;
@@ -10,13 +8,13 @@ ws.addEventListener("message", ev => {
const msg = JSON.parse(ev.data);
// check if api.msg.handle has a handler for message type
- if (!api.msg.handle.hasOwnProperty(msg[msgTypeKey])) {
- console.warn(`No message handler for type ${msg[msgTypeKey]}`, msg);
+ if (!api.msg.handle.hasOwnProperty(msg.type)) {
+ console.warn(`No message handler for type ${msg.type}`, msg);
return;
}
// run the appropriate message handler
- api.msg.handle[msg[msgTypeKey]](msg);
+ api.msg.handle[msg.type](msg);
});
ws.addEventListener("close", () => {