add demo script using websockets and asyncio
This commit is contained in:
		| @ -3,13 +3,14 @@ | ||||
| <div id="data"></div> | ||||
| <script src="https://code.jquery.com/jquery-3.6.3.min.js"></script> | ||||
| <script> | ||||
|     let socket = new WebSocket("ws://localhost:5000/testProject"); | ||||
|     let socket = new WebSocket("ws://localhost:5000"); | ||||
|     let projectID = "1234"; // hier project ID eintragen | ||||
|  | ||||
|     function setVariable(name, value) { | ||||
|         console.log(`Setting variable: ${name} = ${value}`); | ||||
|         socket.send(JSON.stringify({ | ||||
|             method: "set", | ||||
|             project_id: projectID, | ||||
|             name, | ||||
|             value | ||||
|         })); | ||||
| @ -21,8 +22,10 @@ | ||||
|       socket.send(JSON.stringify({ | ||||
|         method: "handshake", | ||||
|         project_id: projectID, | ||||
|         user: "testClientHtml" | ||||
|         user: "testClient"+Math.random() | ||||
|       })); | ||||
|  | ||||
|       setInterval(function() { setVariable('test',Math.random()) }, Math.random(3)*1000); | ||||
|     }; | ||||
|  | ||||
|     socket.onmessage = function(event) { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user