0

我正在使用 signalR 构建一个实时网站。我有 2 个集线器:

  • 通知中心核心
  • NotificationHub(继承 NotificationHubCore)

我的解决方案包括 2 个小项目:Domain & Web。我将NotificationHubCore 放在 Domain 中NotificationHub 放在 Web 中

现在,在网页部分,我想使用以下方法访问 NotificationHubCore:

 GlobalHost.ConnectionManager.GetHubContext<NotificationHubCore>();

它总是返回 null 给我。

我的问题是:如何通过 NotificationHub 访问 NotificationHubCore。

我试过了:

var notificationHub = new NotificationHub();
GlobalHost.DependencyResolver.Register(typeof(NotificationHubCore), () => notificationHub);

但这种方式并没有奏效。

任何人都可以帮助我吗?

谢谢,

4

1 回答 1

0

您可以使用 SQL Server 在部署在两个单独应用程序中的 SignalR 应用程序之间分发消息。

创建一个新的数据库供背板使用。您可以给数据库起任何名称。您不需要在数据库中创建任何表;背板将创建必要的表。

有关更多详细信息,请参阅本文和“使用 SQL Server 横向扩展”部分 -为什么使用 SignalR

于 2016-11-16T02:09:39.523 回答