Skip to content
davidfowl edited this page Apr 8, 2012 · 29 revisions

Extensiblity

SignalR is built with dependency injection in mind. You can replace most of SignalR pieces with your own implementations and even replace the IDependencyResolver with one of your own. If you're familiar with DI in ASP.NET MVC, then it should feel similar.

Replacing individual components

You can replace individual parts of SignalR without replacing the DependencyResolver by calling dependencyResolver.Register(type, Func<object>):

AspNetHost.DependencyResolver.Register(typeof(IConnectionIdFactory), () => new CustomIdFactory());

Replaceable components

The following lists the pluggable interfaces in SignalR.

  • IMessageBus - Message bus.
  • IConnectionIdFactory - Generates client ids.
  • IHubLocator - Locates all available hubs.
  • IHubTypeResolver - Resolves hub type from a hub name.
  • IHubActivator - Creates hub instances from a type.
  • IHubFactory - Creates hub instances from a hub name.
  • IJavaScriptProxyGenerator - Generates the client proxy for hubs.

Replacing the DependencyResolver (ASP.NET)

You can change the DependencyResolver to use your DI container of choice by calling AspNetHost.SetResolver. There are already some implementations in the community:

Clone this wiki locally