Andrej Studen/Merlin 3 лет назад
Сommit
4bdef5e314
1 измененных файлов с 22 добавлено и 0 удалено
  1. 22 0
      send.py

+ 22 - 0
send.py

@@ -0,0 +1,22 @@
+import asyncio
+import websockets
+import sys
+
+async def hello(message):
+        uri = "ws://193.2.68.227:8765"
+        async with websockets.connect(uri) as websocket:
+            print('Sending {}'.format(message))
+
+            await websocket.send(message)
+            print(">>> {}".format(message))
+            #receive nothing
+            #greeting = await websocket.recv()
+            #print(f"<<< {greeting}")
+
+if __name__ == "__main__":
+    message=sys.argv[1]
+    loop = asyncio.get_event_loop()
+    # Blocking call which returns when the hello_world() coroutine is done
+    loop.run_until_complete(hello(message))
+    loop.close()
+