The .NET core client for signalr have a HubConnection
class that can be used in the following way.
HubConnection connection = new HubConnectionBuilder()
.WithUrl("https://localhost:44321/hub")
.Build();
await connection.StartAsync();
connection.On<SomeEvent>("HubMethodName", (ev) => Console.WriteLine("EventHandler"))
I want to do some asynchronous work in the event handler, but it is not immediately obvious to me how, since most of the overloads expection an Action
. Using async void
works, but I'm not sure that's a good idea. Also, there is an overload with the signature On(string methodName, Type[] parameters, Func<object[], Task>) handler)
which is promising, but I guess I would have expected one with On<T>(string methodName, Func<T, Task> handler)
. I can make an extension method with that signature myself, but when it is not there to begin with, I'm thinking that I've might have missed something important?