A websocket library for curio + trio
Project description
asyncwebsockets
=======
asyncwebsockets is a `curio`_ + `trio`_ compatible library for connecting and serving websockets.
Installation
------------
To install the latest stable version::
$ pip install asyncwebsockets
To install the latest development version::
$ pip install git+https://github.com/SunDwarf/asyncwebsockets.git#egg=asyncwebsockets
Basic Usage
-----------
.. code-block:: python3
import multio
from asyncwebsockets.client import connect_websocket
from asyncwebsockets.ws import WebsocketConnectionEstablished, WebsocketBytesMessage
async def test():
sock = await connect_websocket("wss://echo.websocket.org", reconnecting=False)
async for message in sock:
print("Event received", message)
if isinstance(message, WebsocketConnectionEstablished):
await sock.send_message(b"test")
elif isinstance(message, WebsocketBytesMessage):
print("Got response:", message.data)
await sock.close(code=1000, reason="Thank you!")
multio.init("curio")
multio.run(main)
.. _curio: https://curio.readthedocs.io/en/latest/
.. _trio: https://trio.readthedocs.io/en/latest/
=======
asyncwebsockets is a `curio`_ + `trio`_ compatible library for connecting and serving websockets.
Installation
------------
To install the latest stable version::
$ pip install asyncwebsockets
To install the latest development version::
$ pip install git+https://github.com/SunDwarf/asyncwebsockets.git#egg=asyncwebsockets
Basic Usage
-----------
.. code-block:: python3
import multio
from asyncwebsockets.client import connect_websocket
from asyncwebsockets.ws import WebsocketConnectionEstablished, WebsocketBytesMessage
async def test():
sock = await connect_websocket("wss://echo.websocket.org", reconnecting=False)
async for message in sock:
print("Event received", message)
if isinstance(message, WebsocketConnectionEstablished):
await sock.send_message(b"test")
elif isinstance(message, WebsocketBytesMessage):
print("Got response:", message.data)
await sock.close(code=1000, reason="Thank you!")
multio.init("curio")
multio.run(main)
.. _curio: https://curio.readthedocs.io/en/latest/
.. _trio: https://trio.readthedocs.io/en/latest/
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
asyncwebsockets-0.2.1.tar.gz
(9.3 kB
view hashes)
Built Distributions
asyncwebsockets-0.2.1-py3.6.egg
(13.3 kB
view hashes)
Close
Hashes for asyncwebsockets-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a3a6b4d5b6db1d94f6d3e0b8fd1689578a0c58f612fef058e23feec130918fe |
|
MD5 | 76dfe212e6c00a7124c9e6a23899bf95 |
|
BLAKE2b-256 | f919c654fed2c0ca75d32a8f9bb9fdfd837d5a4f0de0cb23ac4389df614a2d39 |