Skip to main content

Asynchronous fork of signalrcore with MessagePack support: A Python SignalR Core client, with invocation auth and two way streaming. Compatible with azure / serverless functions. Also with automatic reconnect and manual reconnect.

Project description

SignalR core client

Pypi Pypi - downloads month

This signalr core client is forked from mandrewcito. The main difference is the replacement of the synchronous websocket-client library by the asynchronous websockets library. Additionally, all methods have been made asynchronous.

See https://github.com/mandrewcito/signalrcore for a general introduction.

See the following samples to get an idea of the changes:

import asyncio

from signalrcore_async.hub_connection_builder import HubConnectionBuilder
from signalrcore_async.protocol.msgpack import MessagePackHubProtocol

async def main():

    protocol = "ws"
    host = "localhost"
    port = "8080"
    hub = "hub"
    hub_url = f"{protocol}://{host}:{port}/{hub}"

    connection = HubConnectionBuilder()\
                .with_url(hub_url)\
                # optional: use MessagePack instead of json protocol
                .with_hub_protocol(MessagePackHubProtocol())\
                .build()

    try:
        # start connection
        await connection.start()

        # send (fire and forget)
        connection.send("SendName", "R2D2")

        # invoke (wait for return value)
        sum_value = await connection.invoke("Sum", [1, 2])
        print(sum_value)

        # register callback
        connection.on("OnProgressChanged", _on_progress_changed)

        # stream
        await connection.stream("StreamData", [1, 2], _on_next)

    finally:
        # close connection
        await connection.stop()

def _on_next(data):
    pass # do something with the streamed data

def _on_progress_changed(self, args):
    progress = args[0]
    print(f"Progress: {progress * 100:.0f}%")

# run main task
asyncio.run(main())

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

signalrcore-async-0.5.4.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

signalrcore_async-0.5.4-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file signalrcore-async-0.5.4.tar.gz.

File metadata

  • Download URL: signalrcore-async-0.5.4.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for signalrcore-async-0.5.4.tar.gz
Algorithm Hash digest
SHA256 60e662633ca09666786f56849385fde6aa81ec95a08f20a737f886145546c5b0
MD5 6d429845bbdb3ed7240a932c9574f166
BLAKE2b-256 9634af6947d602b070126be51c1157c473ccbed47b9c96305f76b8359f52cc5c

See more details on using hashes here.

File details

Details for the file signalrcore_async-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: signalrcore_async-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for signalrcore_async-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 875a1d085281bdec19b6421a77355290e84645b8b5c14002126ec3bc3d8ede51
MD5 bf76a4c1c13999ed27e9c1df019067bc
BLAKE2b-256 6064904689cfc3e5fdfe291c1e11df0aa6e1a6b40785acaf6f308e8c5492bf8d

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