...

/

Using HubContext to Send Messages from Outside SignalR Hub

Using HubContext to Send Messages from Outside SignalR Hub

Understand how HubContext can be used in our application in the context of a distributed SignalR Hub.

Overview

SignalR comes with the IHubContext interface, the implementations of which allow us to access all fields of a specific SignalR Hub, including its groups, clients, and so on. We don’t have to worry about registering any concrete implementations of this interface ourselves. If we inject this interface into the constructor of any class, an appropriate implementation will be automatically resolved. All the dependencies get automatically registered when you call the AddSignalR method on the Services field of the builder object inside the Program.cs class.

HubContext is not designed specifically for a scaled SignalR Hub. We can use it with monolithic SignalR Hubs, too. But, ...