一个的WebAPI和MVC项目之间共享一个SignalR枢纽 [英] Sharing a SignalR hub between a WebApi and MVC project
问题描述
有没有推荐的方法,以在两个应用程序?
分享SignalR枢纽而实际情况是一个面向公众的WebAPI项目和内部Web应用程序的MVC。我想要做的是从的WebAPI项目SignalR枢纽调用方法,并已对这些方法的结果推到通过MVC应用程序连接的客户端。
请问最好的选择是创建第三个中心的项目,并有两个项目连接到?如果是这样,怎么也轮毂实例管理的?这两个应用程序可以从不同的应用程序池(也可能是主机)到同一个集线器的参考?
我读 GlobalHost.ConnectionManager.GetHubContext
一点点,这将足以得到一个有效的其中两个应用程序可以使用一个单中心?
有什么想法大大AP preciated。
只需设置signalr消息通过SQL Server表中的路由。它会使用相同的路由设置自动连接所有枢纽。闲来无事,它的神奇。
<$p$p><$c$c>GlobalHost.DependencyResolver.UseSqlServer(ConfigurationManager.ConnectionStrings[\"signalr\"].ConnectionString);您将需要以下的NuGet包:Microsoft.AspNet.SignalR.SqlServer
Is there a recommended approach to sharing a SignalR hub across two applications?
The actual situation is a public facing WebAPI project and an internal MVC WebApp. What I'd like to do is call methods on a SignalR hub from the WebAPI project and have the results of these methods pushed to clients connected via the MVC app.
Would the best option be to create a third 'Hub' project and have both projects connect to that? If so, how are the hub instances managed? Can both applications get a reference to the same hub from distinct app pools (and possibly hosts)?
I read a little bit about GlobalHost.ConnectionManager.GetHubContext
, would this suffice to get a effectively a singleton hub which both apps could use?
Any thoughts greatly appreciated.
Just setup signalr message routing through a SQL Server table. It will automatically connect all hubs using the same routing setup. Nothing else to do, it's magic.
GlobalHost.DependencyResolver.UseSqlServer(ConfigurationManager.ConnectionStrings["signalr"].ConnectionString);
You will need the following nuget package: Microsoft.AspNet.SignalR.SqlServer
这篇关于一个的WebAPI和MVC项目之间共享一个SignalR枢纽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!