tr2023-client/ws_client.py

23 lines
493 B
Python
Raw Normal View History

#!/usr/bin/env python
import asyncio
import json
from websockets import connect
async def cmd(ws, name, **args):
msg = {
'cmd': name,
'args': args
}
await ws.send(json.dumps(msg))
res = await ws.recv()
print(res)
async def hello(uri):
async with connect(uri) as ws:
await cmd(ws, "ping")
await cmd(ws, "shit")
await cmd(ws, "set_vector", vector_type="trans", vector_args=[1, 0])
asyncio.run(hello("ws://192.168.1.252:1567"))