https://github.com/clamor-py/anysocks
Implementation of the WebSocket protocol on top of anyio
https://github.com/clamor-py/anysocks
asyncio clamor curio library python python3 trio websocket websocket-client websocket-library websockets
Last synced: 9 months ago
JSON representation
Implementation of the WebSocket protocol on top of anyio
- Host: GitHub
- URL: https://github.com/clamor-py/anysocks
- Owner: clamor-py
- License: mit
- Created: 2019-06-24T19:15:48.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-12-01T21:47:28.000Z (over 1 year ago)
- Last Synced: 2024-12-01T22:31:36.767Z (over 1 year ago)
- Topics: asyncio, clamor, curio, library, python, python3, trio, websocket, websocket-client, websocket-library, websockets
- Language: Python
- Homepage: http://anysocks.readthedocs.io/
- Size: 83 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# anysocks
This library implements [the WebSocket protocol](https://tools.ietf.org/html/rfc6455) based on the [Sans-IO library wsproto](https://github.com/python-hyper/wsproto).
I/O is handled by the [anyio project](https://github.com/agronholm/anyio) which makes this library compatible to asyncio, trio and curio.
[](https://actions-badge.atrox.dev/clamor-py/anysocks/goto?ref=master)
[](https://codeclimate.com/github/clamor-py/anysocks/maintainability)
[](https://www.codefactor.io/repository/github/clamor-py/anysocks)
[](https://anysocks.readthedocs.io/en/latest/?badge=latest)
[](https://badge.fury.io/py/anysocks)
## Installation
This library requires Python 3.5+. You can install it directly from PyPI:
```sh
python3 -m pip install -U anysocks
```
If you want the cutting edge development version instead, install it directly from GitHub:
```sh
python3 -m pip install -U git+https://github.com/clamor-py/anysocks@master#egg=anysocks
```
## Documentation
This README only provides a short overview, see the full documentation [here](https://anysocks.readthedocs.io/en/latest).
## Example
```python
import anyio
from anysocks import open_connection
async def main():
async with open_connection('wss://echo.websocket.org') as con:
print('Connection established!')
# First, let's send some text to the server.
text = input('What to send? ')
await con.send_message(text)
# Now, we receive and verify the server's response.
message = await con.get_message()
assert message == text, "Received {}, expected {}".format(message, text)
print('Connection closed with code {}', con.close_code.value)
anyio.run(main)
```