()
| 16 | ws = await aiohttp.ClientSession().ws_connect(url, autoclose=False, autoping=False) |
| 17 | |
| 18 | def stdin_callback(): |
| 19 | line = sys.stdin.buffer.readline().decode('utf-8') |
| 20 | if not line: |
| 21 | loop.stop() |
| 22 | else: |
| 23 | # Queue.put is a coroutine, so you can't call it directly. |
| 24 | asyncio.ensure_future(queue.put(ws.send_str(name + ': ' + line))) |
| 25 | |
| 26 | loop.add_reader(sys.stdin, stdin_callback) |
| 27 |