Closed andig closed 3 years ago
I also have the suspicion, that the code might be racy: if the server sends data before the client.PullStream
has been created these will error. Creating the pull stream before starting the client however panics.
Oh, got it. Shouldn't use streams put public methods.
PullStream pulls a stream from the server. It sends a StreamingInvocation to the server. Maybe the name is missleading. See https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/HubProtocol.md#streaming. The example server does publish its values by calling methods on the server (callbacks, therefore the javascript client is has this 'on' method). But as I wrote here https://github.com/philippseith/signalr/pull/63#issuecomment-922270306, calling methods on the server and the client is barely the same thing, so I decided to implement calling callbacks like calling hub methods, aka as calling public methods of the hub (server) or receiver (client)
FYI streaming has less protocol overhead than calling the client for every new item.
FYI streaming has less protocol overhead than calling the client for every new item.
Not my choice as client…
As I‘m slowly beginning to understand how signalR actually works, I‘m not entirely happy with the API exposed. The extensive use of reflection make it hard to type-check anything at compile time. Exposing the handlers as public methods on the receiver is not self-explanatory. If you should ever consider a 2.0 version it might be nice to make the handlers explicitly configurable per function, maybe something like
f := func(param …interface{}) { … }
party.Handler(„ProductUpdate“, f)
IMHO, type checking is not missing because of the usage of reflection, but because SignalR has no IDL like gPRC or https://github.com/twitchtv/twirp. Reflection is used by the archetypical .net SignalR server and has been brought into the go server by David Fowler himself when he started this project. But you are right: Adding a handler interface is a simple (and simply understood) alternative to the current strategy.
I'm trying to rebuild this example using the go client: https://developer.easee.cloud/page/signalr-code-examples
I'm assuming (I'm new to to SignalR) that
on
is synonym withPullStream
?This is what I have:
Unfortunately, this always errors:
It seems I have no way getting around the
missing method
error?