Created
October 1, 2012 18:18
-
-
Save ChristianWeyer/3813468 to your computer and use it in GitHub Desktop.
Simple ASP.NET Web API & SignalR integration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace WebApi.SignalR | |
{ | |
/// <summary> | |
/// Simple Web API & SignalR integration. | |
/// No access to full hub, e.g. HubCallerContext. | |
/// </summary> | |
/// <typeparam name="THub"></typeparam> | |
public abstract class HubApiController<THub> : ApiController | |
where THub : IHub | |
{ | |
private Lazy<IHubContext> hub = new Lazy<IHubContext>( | |
() => GlobalHost.ConnectionManager.GetHubContext<THub>() | |
); | |
protected string ConnectionId | |
{ | |
get | |
{ | |
var connectionId = new FormDataCollection(Request.RequestUri).Get("connectionId"); | |
return connectionId; | |
} | |
} | |
protected IHubContext Hub | |
{ | |
get { return hub.Value; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment