working websocket server

This commit is contained in:
2023-01-29 21:01:27 +01:00
parent d5f0b09fba
commit a1106c4b22
4 changed files with 105 additions and 6 deletions

View File

@ -4,7 +4,7 @@
<script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
<script>
let socket = new WebSocket("ws://localhost:5000");
let projectID = "1234"; // hier project ID eintragen
let projectID = "einTollesProjekt"; // hier project ID eintragen
function setVariable(name, value) {
console.log(`Setting variable: ${name} = ${value}`);
@ -25,10 +25,11 @@
user: "testClient"+Math.random()
}));
setInterval(function() { setVariable('test',Math.random()) }, Math.random(3)*1000);
setInterval(function() { setVariable('test','einTollerText'+Math.random()) }, 1000);
};
socket.onmessage = function(event) {
console.log(event.data);
for (const message of event.data.split("\n")) {
console.log(`${message}`);
const obj = JSON.parse(message);