Komplett WebSocket Server soweit fertig
This commit is contained in:
commit
4478286a30
3 changed files with 35 additions and 0 deletions
15
client.js
Normal file
15
client.js
Normal 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
10
index.html
Normal 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
10
package.json
Normal 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
|
||||
}
|
||||
Loading…
Reference in a new issue