An event-driven WebSocket library for Python.
Project description
wsaio
An event-driven WebSocket library for Python built on top of asyncio's protocols.
import asyncio
import itertools
import wsaio
URL = 'wss://echo.websocket.org'
class HelloClient(wsaio.WebSocketClient):
@wsaio.async_callback
async def ws_connected(self):
for i in itertools.count():
print(f'[HelloClient] Sending data - COUNT: {i}')
await self.send_str('Hello World')
await asyncio.sleep(5)
def ws_frame_received(self, frame):
print(f'[HelloClient] Received frame - DATA: {frame.data}')
client = HelloClient()
client.loop.create_task(client.connect(URL))
client.loop.run_forever()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wsaio-0.0.1.tar.gz
(5.9 kB
view hashes)
Built Distribution
wsaio-0.0.1-py3-none-any.whl
(10.7 kB
view hashes)