From 21db7b6c5bf6ed3691b9a386298e54f831533d28 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Wed, 26 Feb 2020 11:50:24 -0800 Subject: [PATCH] add a simple pytho echo client --- .../python/websockets/echo_client.py | 25 +++++++++++++++++++ .../python/websockets/empty_file | 0 2 files changed, 25 insertions(+) create mode 100644 test/compatibility/python/websockets/echo_client.py create mode 100644 test/compatibility/python/websockets/empty_file diff --git a/test/compatibility/python/websockets/echo_client.py b/test/compatibility/python/websockets/echo_client.py new file mode 100644 index 00000000..e4083d67 --- /dev/null +++ b/test/compatibility/python/websockets/echo_client.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +# websocket send client + +import argparse +import asyncio +import websockets + + +async def send(url): + async with websockets.connect(url) as ws: + while True: + message = input('> ') + print('Sending message...') + await ws.send(message) + print('Message sent.') + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='websocket proxy.') + parser.add_argument('--url', help='Remote websocket url', + default='wss://echo.websocket.org') + args = parser.parse_args() + + asyncio.get_event_loop().run_until_complete(send(args.url)) diff --git a/test/compatibility/python/websockets/empty_file b/test/compatibility/python/websockets/empty_file new file mode 100644 index 00000000..e69de29b