hss-lattepanda-win-scripts/websockets/speaker_client.py
2024-09-10 13:44:19 +02:00

20 lines
477 B
Python

import asyncio
from websockets.asyncio.client import connect
import websockets
async def init():
uri = "ws://192.168.6.101:3003"
async with connect(uri) as websocket:
await websocket.send("speaker/2")
while True:
try:
await websocket.recv()
except websockets.ConnectionClosed:
print(f"Terminated by server")
break
if __name__ == "__main__":
asyncio.run(init())