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.
Usage
Let's connect to TzKT, indexer and explorer of Tezos blockchain, and subscribe to all operations:
import asyncio
from contextlib import suppress
from typing import Any, Dict, 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():
client = SignalRClient('https://api.tzkt.io/v1/events')
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 to the stable release
- 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-0.1.2.tar.gz
(12.0 kB
view hashes)
Built Distribution
pysignalr-0.1.2-py3-none-any.whl
(14.2 kB
view hashes)
Close
Hashes for pysignalr-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71500f8c299224251ecc74e24e22aee82e1f6f87870ad3eb3a3d52b17be01056 |
|
MD5 | e47632e73c3e62ab7096bd986b8cea0f |
|
BLAKE2b-256 | 30b0bcb78afe1e473b269ab67b922f436ec36250d72a3add8857c2402f141008 |