pysignalr


Namepysignalr JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/baking-bad/pysignalr
SummaryModern, reliable and async-ready client for SignalR protocol
upload_time2024-03-07 15:30:59
maintainerLev Gorodetskii
docs_urlNone
authorLev Gorodetskii
requires_python>=3.8,<4
license
keywords signalr asp client asyncio json messagepack websockets
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pysignalr

[![GitHub stars](https://img.shields.io/github/stars/baking-bad/pysignalr?color=2c2c2c&style=plain)](https://github.com/baking-bad/pysignalr)
[![Latest stable release](https://img.shields.io/github/v/release/baking-bad/pysignalr?label=stable%20release&color=2c2c2c)](https://github.com/baking-bad/pysignalr/releases)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pysignalr?color=2c2c2c)](https://www.python.org)
[![License: MIT](https://img.shields.io/github/license/baking-bad/pysignalr?color=2c2c2c)](https://github.com/baking-bad/pysignalr/blob/master/LICENSE)
<br>
[![PyPI monthly downloads](https://img.shields.io/pypi/dm/pysignalr?color=2c2c2c)](https://pypi.org/project/pysignalr/)
[![GitHub issues](https://img.shields.io/github/issues/baking-bad/pysignalr?color=2c2c2c)](https://github.com/baking-bad/pysignalr/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/baking-bad/pysignalr?color=2c2c2c)](https://github.com/baking-bad/pysignalr/pulls)

**pysignalr** is a modern, reliable, and async-ready client for [SignalR protocol](https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-5.0). This project started as an asyncio fork of mandrewcito's [signalrcore](https://github.com/mandrewcito/signalrcore) library and ended up as a complete rewrite.

## Usage

Let's connect to [TzKT](https://tzkt.io/), an API and block explorer of Tezos blockchain, and subscribe to all operations:

```python
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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/baking-bad/pysignalr",
    "name": "pysignalr",
    "maintainer": "Lev Gorodetskii",
    "docs_url": null,
    "requires_python": ">=3.8,<4",
    "maintainer_email": "pysignalr@drsr.io",
    "keywords": "signalr,asp,client,asyncio,json,messagepack,websockets",
    "author": "Lev Gorodetskii",
    "author_email": "pysignalr@drsr.io",
    "download_url": "https://files.pythonhosted.org/packages/69/db/87754adf0deb82d92175829ebf8c443031bfbe0bdf964375f76fac4b1c03/pysignalr-1.0.0.tar.gz",
    "platform": null,
    "description": "# pysignalr\n\n[![GitHub stars](https://img.shields.io/github/stars/baking-bad/pysignalr?color=2c2c2c&style=plain)](https://github.com/baking-bad/pysignalr)\n[![Latest stable release](https://img.shields.io/github/v/release/baking-bad/pysignalr?label=stable%20release&color=2c2c2c)](https://github.com/baking-bad/pysignalr/releases)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pysignalr?color=2c2c2c)](https://www.python.org)\n[![License: MIT](https://img.shields.io/github/license/baking-bad/pysignalr?color=2c2c2c)](https://github.com/baking-bad/pysignalr/blob/master/LICENSE)\n<br>\n[![PyPI monthly downloads](https://img.shields.io/pypi/dm/pysignalr?color=2c2c2c)](https://pypi.org/project/pysignalr/)\n[![GitHub issues](https://img.shields.io/github/issues/baking-bad/pysignalr?color=2c2c2c)](https://github.com/baking-bad/pysignalr/issues)\n[![GitHub pull requests](https://img.shields.io/github/issues-pr/baking-bad/pysignalr?color=2c2c2c)](https://github.com/baking-bad/pysignalr/pulls)\n\n**pysignalr** is a modern, reliable, and async-ready client for [SignalR protocol](https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-5.0). This project started as an asyncio fork of mandrewcito's [signalrcore](https://github.com/mandrewcito/signalrcore) library and ended up as a complete rewrite.\n\n## Usage\n\nLet's connect to [TzKT](https://tzkt.io/), an API and block explorer of Tezos blockchain, and subscribe to all operations:\n\n```python\nimport asyncio\nfrom contextlib import suppress\nfrom typing import Any\nfrom typing import Dict\nfrom typing import List\n\nfrom pysignalr.client import SignalRClient\nfrom pysignalr.messages import CompletionMessage\n\n\nasync def on_open() -> None:\n    print('Connected to the server')\n\n\nasync def on_close() -> None:\n    print('Disconnected from the server')\n\n\nasync def on_message(message: List[Dict[str, Any]]) -> None:\n    print(f'Received message: {message}')\n\n\nasync def on_error(message: CompletionMessage) -> None:\n    print(f'Received error: {message.error}')\n\n\nasync def main() -> None:\n    client = SignalRClient('https://api.tzkt.io/v1/ws')\n\n    client.on_open(on_open)\n    client.on_close(on_close)\n    client.on_error(on_error)\n    client.on('operations', on_message)\n\n    await asyncio.gather(\n        client.run(),\n        client.send('SubscribeToOperations', [{}]),\n    )\n\n\nwith suppress(KeyboardInterrupt, asyncio.CancelledError):\n    asyncio.run(main())\n```\n\n## Roadmap\n\n- [ ] More documentation, both internal and user.\n- [ ] Integration tests with containerized ASP hello-world server.\n- [ ] Ensure that authentication works correctly.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Modern, reliable and async-ready client for SignalR protocol",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/baking-bad/pysignalr",
        "Repository": "https://github.com/baking-bad/pysignalr"
    },
    "split_keywords": [
        "signalr",
        "asp",
        "client",
        "asyncio",
        "json",
        "messagepack",
        "websockets"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f589384ce9178f7599814a9524f826f527ccc8e4959ce75e3939d668e6a17e0e",
                "md5": "987eb4d79ebdfefcc51637e8abfc686f",
                "sha256": "735cdb93a337610c1504ada08b55709886076a34f1b03cdcbd49d3365e87cb16"
            },
            "downloads": -1,
            "filename": "pysignalr-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "987eb4d79ebdfefcc51637e8abfc686f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4",
            "size": 14984,
            "upload_time": "2024-03-07T15:30:58",
            "upload_time_iso_8601": "2024-03-07T15:30:58.020321Z",
            "url": "https://files.pythonhosted.org/packages/f5/89/384ce9178f7599814a9524f826f527ccc8e4959ce75e3939d668e6a17e0e/pysignalr-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69db87754adf0deb82d92175829ebf8c443031bfbe0bdf964375f76fac4b1c03",
                "md5": "3dcefd5f8445b4e5b0c3210559ff2642",
                "sha256": "241b0a3af24e674915c10e2f53feefe421f8202b972d8be296e3da52b0f88073"
            },
            "downloads": -1,
            "filename": "pysignalr-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3dcefd5f8445b4e5b0c3210559ff2642",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4",
            "size": 12628,
            "upload_time": "2024-03-07T15:30:59",
            "upload_time_iso_8601": "2024-03-07T15:30:59.254379Z",
            "url": "https://files.pythonhosted.org/packages/69/db/87754adf0deb82d92175829ebf8c443031bfbe0bdf964375f76fac4b1c03/pysignalr-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-07 15:30:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "baking-bad",
    "github_project": "pysignalr",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pysignalr"
}
        
Elapsed time: 0.38775s