SignalR Hubs in a class library? Is this a good idea or a bad one?
.net, shared-libraries, signalr, web-services
Solution
You can have your SignalR stuff in a class library for sure, but in your case that should probably be a different one from the one you have where the preprocessing happens. The SignalR one would be pure infrastructure, and no business logic would happen, just messaging. You can define some interface in the middle and plug the infrastructure into your preprocessing one. This way the dependency on SignalR is behind an interface, your code is clean, and the dependency on Owin is isolated into the infrastructure.
Problem
I'm fairly new to SignalR. I started writing a hub and putting that logic in a class library. Here's what I'm trying to accomplish: I have a "preprocessor" service that goes off and pre-fetches a number of objects/documents/etc from external sources and puts them into the cache. I am using the hub to communicate to clients when all items have been pre-fetched. We also have several client consumers. Among them include: - a typical MVC app/project - a console app we use for quick testing - a webapi and a WCF/SOAP project for exposing our services to external parties - a unit test project The problem By putting the hub in the class library, I've made all the downstream consumers (including other class libraries) have a dependency on OWIN... and I now need my startup class (and or app config settings to tell Owin to not use it). ``` public class Startup { public void Configuration(IAppBuilder app) { app.MapSignalR(); } } ``` or ``` <add key="owin:AutomaticAppStartup " value="false" /> ``` The Architecture? This 'smells' to me. Maybe SignalR hubs are not meant to be in a class library? If that is the case, what would be a better design? e.g. have the hub in its own WebApi Service? And proxies to this service? That way, my preprocessor logic (contained in a class library) can call the Hub? Suggestions would be greatly appreciated.