Add connection check to cli_sender
This commit is contained in:
parent
a1739c4b7a
commit
cf007ee4fe
1 changed files with 3 additions and 0 deletions
|
@ -6,13 +6,16 @@ import asyncio
|
|||
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from websockets.asyncio.client import ClientConnection
|
||||
from websockets.asyncio.client import connect
|
||||
|
||||
|
||||
async def run(host: str, port: int):
|
||||
ws: ClientConnection
|
||||
async with connect(f"ws://{host}:{port}") as ws:
|
||||
while True:
|
||||
inp = input("> ")
|
||||
await (await ws.ping()) # check connection
|
||||
await ws.send(inp)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue