websocket not working

This commit is contained in:
maxstrb 2025-11-04 18:02:59 +01:00
parent 46ad5b3bf7
commit 964c90d2f2
5 changed files with 136 additions and 54 deletions

View file

@ -4,6 +4,17 @@
<link rel="stylesheet" href="/public/index.css">
<meta charset="UTF-8"/>
<title>Hello World!</title>
<script>
const socket = new WebSocket("ws://localhost:8080/websocket");
socket.addEventListener("open", (event) => {
socket.send("Hello Server!");
});
socket.addEventListener("message", (event) => {
console.log("Message from server ", event.data);
});
</script>
</head>
<body>