2025-09-27 07:36:55 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2025-09-27 07:51:50 +02:00
|
|
|
# Copyright (c) 2025 Julian Müller (ChaoticByte)
|
|
|
|
|
2025-09-27 07:36:55 +02:00
|
|
|
import asyncio
|
|
|
|
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
2025-09-27 12:06:25 +02:00
|
|
|
from websockets.asyncio.client import ClientConnection
|
2025-09-27 07:36:55 +02:00
|
|
|
from websockets.asyncio.client import connect
|
|
|
|
|
|
|
|
|
|
|
|
async def run(host: str, port: int):
|
2025-09-27 12:06:25 +02:00
|
|
|
ws: ClientConnection
|
2025-09-27 07:36:55 +02:00
|
|
|
async with connect(f"ws://{host}:{port}") as ws:
|
|
|
|
while True:
|
|
|
|
inp = input("> ")
|
2025-09-27 12:06:25 +02:00
|
|
|
await (await ws.ping()) # check connection
|
2025-09-27 07:36:55 +02:00
|
|
|
await ws.send(inp)
|
|
|
|
|
2025-09-27 07:51:50 +02:00
|
|
|
|
2025-09-27 07:36:55 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
argp = ArgumentParser()
|
|
|
|
argp.add_argument("host", type=str, help="Node host to connect to")
|
|
|
|
argp.add_argument("port", type=int, help="Node port to connect to")
|
|
|
|
args = argp.parse_args()
|
|
|
|
|
|
|
|
asyncio.run(run(args.host, args.port))
|