Skip to content

SignalR

LightInject.Signal provides an integration that enables dependency injection in SignalR hub implementations.

Installing

LightInject.SignalR provides two distribution models via NuGet

Binary

PM> Install-Package LightInject.SignalR

This adds a reference to the LightInject.SignalR.dll in the target project.

Source

PM> Install-Package LightInject.SignalR.Source

This will install a single file (LightInject.SignalR.cs) into the current project.

Initializing

The following example shows how to enable support for SignalR in an OWIN startup class.

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        var serviceContainer = new ServiceContainer();
        serviceContainer.RegisterHubs();            
        ..register other services

        app.MapSignalR(serviceContainer.EnableSignalR());
    }
}

Services

Services that implements IDisposable must be registered with the with the PerScopeLifetime or the PerRequestLifetime to ensure that they are properly disposed when the Hub is disposed.