Extending the Hub pipeline
Among all the services that SignalR exposes and lets us customize, there is one that is particularly interesting: IHubPipeline
. This service, as its name clearly states, represents the full pipeline that underpins a Hub, and its goal is to collect a set of modules to be executed during the initialization of a Hub. Each module implements IHubPipelineModule
, and each method exposed by this contract is executed during the bootstrap phase. The job of those methods is to provide a factory methods that SignalR will then invoke during specific moments in the lifetime of every instance of a Hub. There are factories to build incoming and outgoing Hub invocations; to perform connection, reconnection, and disconnection tasks; to authorize connections; and to handle whether a client can rejoin groups on reconnection.
Thanks to the dependency injection mechanism we've been analyzing earlier, we could replace the IHubPipeline
service with our custom implementation, but that would...