Skip to main content

Simple SignalR client for Python

Project description

Python client proxy for SignalR.

Requirements

Install requirements by running:

pip install -r requirements

Signalr client is based on gevent which in turn requires Python headers. In Debian based distributions (such as Ubuntu and Raspbian) they are called python-dev.

Compatibility

Compatible with Python 2 and 3.

Usage

Here is sample usage:

from requests import Session
from signalr import Connection

with Session() as session:
    #create a connection
    connection = Connection("http://localhost:5000/signalr", session)

    #get chat hub
    chat = connection.register_hub('chat')

    #start a connection
    connection.start()

    #create new chat message handler
    def print_received_message(data):
        print('received: ', data)

    #create new chat topic handler
    def print_topic(topic, user):
        print('topic: ', topic, user)

    #create error handler
    def print_error(error):
        print('error: ', error)

    #receive new chat messages from the hub
    chat.client.on('newMessageReceived', print_received_message)

    #change chat topic
    chat.client.on('topicChanged', print_topic)

    #process errors
    connection.error += print_error

    #start connection, optionally can be connection.start()
    with connection:

        #post new message
        chat.server.invoke('send', 'Python is here')

        #change chat topic
        chat.server.invoke('setTopic', 'Welcome python!')

        #invoke server method that throws error
        chat.server.invoke('requestError')

        #post another message
        chat.server.invoke('send', 'Bye-bye!')

        #wait a second before exit
        connection.wait(1)

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

signalr-client-0.0.6.zip (9.9 kB view details)

Uploaded Source

Built Distributions

signalr_client-0.0.6-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

signalr_client-0.0.6-py2-none-any.whl (9.3 kB view details)

Uploaded Python 2

File details

Details for the file signalr-client-0.0.6.zip.

File metadata

  • Download URL: signalr-client-0.0.6.zip
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for signalr-client-0.0.6.zip
Algorithm Hash digest
SHA256 c3c588c2cc7f610ac23290723632104e5e71b9391ac813731930528a1d578646
MD5 0c3775b5ec46823fbab5fdabab294e71
BLAKE2b-256 93d48053995592853c24227d0f8d41672d82b54cce95dc95e81adba25a4a6e65

See more details on using hashes here.

File details

Details for the file signalr_client-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for signalr_client-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 303aa6a73be5a886a6c26b25290752f84f5809ec5b05727da653c236650d5115
MD5 90a40e5fd8b39c5555e5f73906a695ec
BLAKE2b-256 c4e5002a85cc2c665d0d8901a05654f6b6c69737ba9d437bba70d24b2ec93a56

See more details on using hashes here.

File details

Details for the file signalr_client-0.0.6-py2-none-any.whl.

File metadata

File hashes

Hashes for signalr_client-0.0.6-py2-none-any.whl
Algorithm Hash digest
SHA256 e2dc314f8440fffa330beaa920595c74d8d41dfe229549ca251c362934516b21
MD5 15d96e4a7f8574d92226c88d618f615a
BLAKE2b-256 ec1feec7eb197ee9e639dea5f5eb226969cb03cf621928847e4bbf06be3cba82

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page