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 argparse import ArgumentParser
|
||||||
|
|
||||||
|
from websockets.asyncio.client import ClientConnection
|
||||||
from websockets.asyncio.client import connect
|
from websockets.asyncio.client import connect
|
||||||
|
|
||||||
|
|
||||||
async def run(host: str, port: int):
|
async def run(host: str, port: int):
|
||||||
|
ws: ClientConnection
|
||||||
async with connect(f"ws://{host}:{port}") as ws:
|
async with connect(f"ws://{host}:{port}") as ws:
|
||||||
while True:
|
while True:
|
||||||
inp = input("> ")
|
inp = input("> ")
|
||||||
|
await (await ws.ping()) # check connection
|
||||||
await ws.send(inp)
|
await ws.send(inp)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue