Modern, reliable and async-ready client for SignalR protocol
Project description
pysignalr
pysignalr is a modern, reliable, and async-ready client for SignalR protocol. This project started as an asyncio fork of mandrewcito's signalrcore library and ended up as a complete rewrite.
Usage
Let's connect to TzKT, an API and block explorer of Tezos blockchain, and subscribe to all operations:
import asyncio
from contextlib import suppress
from typing import Any
from typing import Dict
from typing import List
from pysignalr.client import SignalRClient
from pysignalr.messages import CompletionMessage
async def on_open() -> None:
print('Connected to the server')
async def on_close() -> None:
print('Disconnected from the server')
async def on_message(message: List[Dict[str, Any]]) -> None:
print(f'Received message: {message}')
async def on_error(message: CompletionMessage) -> None:
print(f'Received error: {message.error}')
async def main() -> None:
client = SignalRClient('https://api.tzkt.io/v1/ws')
client.on_open(on_open)
client.on_close(on_close)
client.on_error(on_error)
client.on('operations', on_message)
await asyncio.gather(
client.run(),
client.send('SubscribeToOperations', [{}]),
)
with suppress(KeyboardInterrupt, asyncio.CancelledError):
asyncio.run(main())
Roadmap
- More documentation, both internal and user.
- Integration tests with containerized ASP hello-world server.
- Ensure that authentication works correctly.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pysignalr-1.0.0.tar.gz
(12.6 kB
view details)
Built Distribution
pysignalr-1.0.0-py3-none-any.whl
(15.0 kB
view details)
File details
Details for the file pysignalr-1.0.0.tar.gz
.
File metadata
- Download URL: pysignalr-1.0.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1015-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 241b0a3af24e674915c10e2f53feefe421f8202b972d8be296e3da52b0f88073 |
|
MD5 | 3dcefd5f8445b4e5b0c3210559ff2642 |
|
BLAKE2b-256 | 69db87754adf0deb82d92175829ebf8c443031bfbe0bdf964375f76fac4b1c03 |
File details
Details for the file pysignalr-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pysignalr-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1015-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 735cdb93a337610c1504ada08b55709886076a34f1b03cdcbd49d3365e87cb16 |
|
MD5 | 987eb4d79ebdfefcc51637e8abfc686f |
|
BLAKE2b-256 | f589384ce9178f7599814a9524f826f527ccc8e4959ce75e3939d668e6a17e0e |