Skip to main content

Async fork of Python SignalR Core client(json and messagepack), with invocation auth and two way streaming. Compatible with azure / serverless functions. Also with automatic reconnect and manually reconnect.

Project description

SignalR core client (async fork)

Pypi

This is asyncio version of the original SignalR Core library.
The main difference is that websocket library is replaced with asyncio-compatabile websockets.
All future changes in the original repo will be merged to this fork inheriting the major and minor version number.

Installation

pip install aiosignalrcore

Usage

Check out the docs of the original library.
The names of all modules, classes, and methods are preserved.

Async example

import asyncio
import logging
from aiosignalrcore.hub_connection_builder import HubConnectionBuilder
from aiosignalrcore.messages.completion_message import CompletionMessage
from aiosignalrcore.transport.websockets.connection import ConnectionState


hub_connection = (
    HubConnectionBuilder()
        .with_url('%URL%')
        .with_automatic_reconnect(
            {
                "type": "raw",
                "keep_alive_interval": 10,
                "reconnect_interval": 5,
                "max_attempts": 5,
            }
        )
        .build()
)


async def on_connect():
    logging.info('Connected to the server')
    
    while hub_connection.transport.state != ConnectionState.connected:
        await asyncio.sleep(0.1)

    await hub_connection.send("SendMessage", [])


async def on_message(message):
    pass


def on_error(self, message: CompletionMessage):
    raise Exception(message.error)


hub_connection.on_open(on_connect)
hub_connection.on_error(on_error)
hub_connection.on("Message", on_message)

await hub_connection.start()

try:
    while hub_connection.transport.state == ConnectionState.connected:
        await asyncio.sleep(1)
except KeyboardInterrupt:
    pass
finally:
    await hub_connection.stop()

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

aiosignalrcore-0.9.2.2.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

aiosignalrcore-0.9.2.2-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file aiosignalrcore-0.9.2.2.tar.gz.

File metadata

  • Download URL: aiosignalrcore-0.9.2.2.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.6.14 Linux/5.8.0-1039-azure

File hashes

Hashes for aiosignalrcore-0.9.2.2.tar.gz
Algorithm Hash digest
SHA256 8f4250e510c12f1b25bb8b6dedf0be87ed7b27256023d06c37d97baa5f29f495
MD5 bebec485b0c19ca659bf820312c72fa0
BLAKE2b-256 4c543b96fac008003c5ade2c2b0b01eba8232c81a16fa232ea6f73b0875957f3

See more details on using hashes here.

File details

Details for the file aiosignalrcore-0.9.2.2-py3-none-any.whl.

File metadata

  • Download URL: aiosignalrcore-0.9.2.2-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.6.14 Linux/5.8.0-1039-azure

File hashes

Hashes for aiosignalrcore-0.9.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1b2f1d6b4fe216334ba3ef53083e44213d50c86f7652682e3904300a5755c9b3
MD5 e6a94fdf33be4e685f0448c1d1f02b85
BLAKE2b-256 b6749944dd5764710627867069bb5458f76794a2e789c9d068baa041dc7a58f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page