Owin & SignalR integration

243 views
Skip to first unread message

matei....@gmail.com

unread,
Aug 17, 2015, 8:32:18 AM8/17/15
to Autofac
Hello!

I have a web application where I use Autofac for most of my dependencies, so I decided to install Autofac.Integration.SignalR in order to resolve my dependencies inside my hubs.

Now, because it is a WebAPI application, I have an Owin Startup class where I configure the middleware that I need. (I also installed Integration.Owin).

Now, in the official documentation it states the following: "A common error in OWIN integration is use of the GlobalHost. In OWIN you create the configuration from scratch. You should not reference GlobalHost anywhere when using the OWIN integration."

How am I supposed to have acces to updating the SignalR clients outside the hub (most of my application needs to do this) if I can't use GlobalHost?

What is considered best practice in this scenario?

Thanks!

Alex Meyer-Gleaves

unread,
Aug 17, 2015, 9:34:07 AM8/17/15
to 'maverick02k1@yahoo.com' via Autofac
Hi Maverick,

You should still be able to access the hub through GlobalHost.ConnectionManager.GetHubContext. The warning really applies to configuration where using GlobalHost is a common mistake. I think we could improve the wording in the documentation to clear that up, and probably add a section on accessing hubs on the server. It is also possible to resolve the IConnectionManager and call GetHubContext on that too. If you do use GlobalHost I would recommend creating a wrapper interface like IHubContextProvider for access to the hub context so you can mock it out in your tests.

Cheers,

Alex.
--
You received this message because you are subscribed to the Google Groups "Autofac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autofac+u...@googlegroups.com.
To post to this group, send email to aut...@googlegroups.com.
Visit this group at http://groups.google.com/group/autofac.
For more options, visit https://groups.google.com/d/optout.

wallac...@gmail.com

unread,
Sep 24, 2015, 12:27:00 AM9/24/15
to Autofac
>It is also possible to resolve the IConnectionManager and call GetHubContext on that too.

How? do you need to register it yourself? I am assuming yes but where does it live initially so you can register it?
Reply all
Reply to author
Forward
0 new messages