diff --git a/src/controllers/UserWebSocketController.ts b/src/controllers/UserWebSocketController.ts index c446176..c7854aa 100644 --- a/src/controllers/UserWebSocketController.ts +++ b/src/controllers/UserWebSocketController.ts @@ -118,8 +118,26 @@ export class UserWebSocketController { this.active_clients.splice(this.active_clients.indexOf(client), 1); }) + // Handles error + ws.addEventListener("error", (e) => { + if(ws.readyState == ws.OPEN) + ws.close(); + + console.log("WebSocket error", e) + }) - console.log(this.active_clients) + // Handles incoming messages + ws.addEventListener("message", (msg) => { + + // Only accept text messages + if(msg.type != "message") { + console.error("Received a non-text messsage through a WebSocket !") + ws.close(); + return; + } + + + }) } /**