Client-initiated events
However, we’ve only worked on a server-to-client broadcast: what if we want to send something from our client to the server? It’s true that we have a URL endpoint to test our update message, but could we send it from the hubConnection
instead?
As a matter of fact, we can, and it’s actually quite simple to implement since we already did most of the required groundwork.
More precisely, here’s what we need to do:
- Update the HealthCheckHub at the server-side level, to give clients the chance to invoke an Update method
- Update the HealthCheckComponent at the client-side level, to actually invoke the method
- Test it to see if everything works as expected
Let’s do this.
Updating the HealthCheckHub
As we already know, the SignalR Hub
allows a bi-directional data exchange, meaning that clients can send data through it; however, if we want to allow such behavior, we need to implement the...