vcs-python-repository/Server/testing servers/dummy_camera_server.py
2024-05-29 12:40:19 -05:00

30 lines
No EOL
735 B
Python

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()
# await update_from_packet(data)
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", 8765)
print("server started")
await server.wait_closed()
asyncio.run(main())