1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-22 05:19:22 +00:00

Accept only text messages on WebSocket

This commit is contained in:
Pierre HUBERT 2020-03-30 14:45:29 +02:00
parent 729ee6a2a9
commit 587f482736

View File

@ -118,8 +118,26 @@ export class UserWebSocketController {
this.active_clients.splice(this.active_clients.indexOf(client), 1); 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;
}
})
} }
/** /**