Komplett WebSocket Server soweit fertig

This commit is contained in:
Eduard Wisch 2025-03-16 18:33:48 +01:00
commit 4478286a30
3 changed files with 35 additions and 0 deletions

15
client.js Normal file
View file

@ -0,0 +1,15 @@
console.log('Script Loaded')
const ws = new WebSocket("ws://localhost:8000");
ws.onopen = function (openEvent) {
console.log("WebSocket ist mit dem " + ws.protocol + "Protokoll geöffnet");
ws.send("Hallo Server");
}
ws.onmessage = function (messageEvent) {
console.log(messageEvent.data);
}
ws.onclose = function (closeEvent) {
console.log("Websocket wurde geschlossen")
}

10
index.html Normal file
View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Websocket Client</title>
</head>
<body>
<script src="client.js"></script>
</body>
</html>

10
package.json Normal file
View file

@ -0,0 +1,10 @@
{
"name": "client",
"version": "1.0.0",
"description": "",
"main": "client.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"private": true
}