Reputation: 3569
I have two hubs in my application. For the one I need NTLM authentication, and IP based filtering for the other. For this to work I need to set HttpListener.AuthenticationSchemes
to AuthenticationSchemes.Ntlm
for the first, while it remains Anonymous for the other. This means that I can not have both hubs running on the same listener connection.
I have my OwinMiddleware
to handle the authentication, and I am trying to set up two different endpoints for these two hubs (two different ports).
My problem is that when I don't know how to tell SignalR to map only a specific hub to specific IAppBuilder
, and not all hubs that it can find. Any idea?
Upvotes: 1
Views: 762
Reputation: 3569
Finally, I managed to solve this using custom IAddemblyLocator
. I wrote an article about this: https://www.codeproject.com/Tips/1237940/One-Possible-Way-of-Selectively-Assigning-Hubs-to
The basic idea is this:
using (WebApp.Start("http://*:8080", (app) => {
var resolver = new DefaultDependencyResolver();
var locator = new SingleAssemblyLocator(typeof(MyFirstHub).Assembly);
resolver.Register(typeof(IAssemblyLocator), () => locator);
app.MapSignalR(new HubConfiguration { Resolver = resolver });
}))
{
Console.WriteLine("Server running on {0}", url);
Console.ReadLine();
}
Where SingleAssemblyLocator.GetAssemblies()
is returning only the assembly passed to the constructor. Of course, each WebApp
can be configured as needed.
Upvotes: 2