Compare commits

..

2 commits

Author SHA1 Message Date
Nickiel12
420e0b327a version bump 2024-05-29 12:40:29 -05:00
Nickiel12
d23b3c711e added more robust testing dummy servers 2024-05-29 12:40:19 -05:00
3 changed files with 63 additions and 30 deletions

View file

@ -0,0 +1,33 @@
import asyncio
import websockets
socket_connections = {}
async def handle_client(websocket, path):
global socket_connections
print("packet connected")
socket_connections[websocket] = ""
try:
while True:
print("waiting for data")
data = await websocket.recv()
if data == "Type?":
await websocket.send("Automated")
else:
await websocket.send("[1] 100:100 200:700\n[2] 250:250 750:750\n[3] 500:300 800:800")
except websockets.exceptions.ConnectionClosed:
print("Connection closed with: ", websocket.remote_address)
finally:
print("closing websocket")
del socket_connections[websocket]
async def main():
server = await websockets.serve(handle_client, "localhost", 6543)
print("server started")
await server.wait_closed()
asyncio.run(main())

@ -1 +1 @@
Subproject commit 36e5afeb579ee6242748d909a820232edeafc866
Subproject commit f6b9c50e7ebb7b330037ab8aef3e2d58e7eef7aa