feat(ui): Websocket

Added simple websocket. Serverside websocket logic isnt in the usersession
This commit is contained in:
LQ63
2025-11-21 17:11:16 +01:00
committed by Janis
parent 2bc50664e0
commit 09cc96141d
4 changed files with 74 additions and 1 deletions

View File

@@ -664,4 +664,23 @@ function sendPlayCardRequest(jsonObj, gameId, cardobject, dog) {
})
})
}
const ws = new WebSocket("ws://localhost:9000/websocket");
ws.onopen = (event) => {
console.log("WebSocket connection established!");
ws.send("Client is now connected and ready.");
};
ws.onmessage = (event) => {
console.log("SERVER RESPONSE:", event.data);
};
ws.onerror = (error) => {
console.error("WebSocket Error:", error);
};
ws.onclose = (event) => {
if (event.wasClean) {
console.log(`Connection closed cleanly, code=${event.code} reason=${event.reason}`);
} else {
console.warn('Connection died unexpectedly.');
}
};