loading...
Cover image for SignalR core python client (III): Streamming

SignalR core python client (III): Streamming

mandrewcito profile image Andrés Baamonde Lozano ・2 min read

Sunday's hangover, so I added a new functionality to my singalrcore library, as usual it works with the microsoft example and i'll try making the syntax closest thing to javascript as possible.

Setup

On Microsoft's example there is a cancellation token on stream function on the server, this example was done without this parameter on the function, so if you want work with the code below just delete this params on the counter function.
Code function

Tiny example

Start and open connection

hub_connection = HubConnection(server_url)
hub_connection.build()
hub_connection.start()
Enter fullscreen mode Exit fullscreen mode

Open stream

hub_connection.stream(
    "Counter",
    [10, 500],
    lambda x: print("next callback: ", x),
    lambda x: print("complete  callback", x),
    lambda x: print("error  callback", x))
Enter fullscreen mode Exit fullscreen mode

Stream function has five parameters, last three are callback function matching with javascripts suscribe object
Javascript example stream

Fully example

ToDo

  • message pack
  • Auth (now only working by querystring negotiate)

Links

Github
Pypi

I'm trying to build this library with simplest way possible, so if you think that there is a better way to do it, leave a comment. Asap i'll edit github library contribute section, so any contribution is welcommed.

Thank you for reading, and write any thought below :D

Discussion

pic
Editor guide