Add connection check to cli_sender

This commit is contained in:
ChaoticByte 2025-09-27 12:06:25 +02:00
parent a1739c4b7a
commit cf007ee4fe
No known key found for this signature in database

View file

@ -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)