forked from SignalR/SignalR
-
Notifications
You must be signed in to change notification settings - Fork 0
Extensibility
davidfowl edited this page Nov 8, 2011
·
29 revisions
SignalR is built with dependency injection in mind. You can replace most of SignalR pieces with your own implementations and even replace the DependencyResolver with one of your own. If you're familiar with DI in ASP.NET MVC, then it should feel similar.
You can replace individual parts of SignalR without replacing the DependencyResolver by calling DependencyResolver.Register(type, Func<object>):
DependencyResolver.Register(typeof(IClientIdFactory), () => new CustomIdFactory());
The following lists the pluggable interfaces in SignalR.
-
IMessageStore- Stores messages that are broadcast. -
ISignalBus- Pub sub backing store. -
IClientIdFactory- Generates client ids. -
IJsonStringifier- Serializes objects into JSON. -
IPersistentConnectionFactory- Creates persistent connection instances. -
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.
You can change the DependencyResolver to use your DI container of choice by calling DependencyResolver.SetResolver. There are already some implementations in the community: