Pregunta

I have an MVC website sitting onto of some fairly hefty business objects. My MVC Controllers call Manager objects which conducts and delegates work off to other sets of objects.

Basically the code is deep server side, while a Hub in a way is just like a Controller in that it is fairly close to the client side.

Is there a way to execute SignalR methods based on a reference to the Hub passed to these Manager objects?

¿Fue útil?

Solución

If your MVC and SignalR services are running on the same process, you can call GlobalHost.ConnectionManager.GetHubContext("MyHub");

It they are on separate processes, then you need to create a SignalR client in your MVC app

Otros consejos

Well all of the clients will connect to your web app and persist the connections there. From a separate back end program you can just call a web service in your web app and that web service can post the message on the same SignalR hub in your web project. Your back end app can't connect to the SignalR hub directly. It all flows through a single point, being your web app.

If you are just talking about a shared class library in the same web app, you should be able to pass the hub object to the other class as the other person answered: GlobalHost.ConnectionManager.GetHubContext("MyHub");

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top