我正在使用 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);
但这种方式并没有奏效。
任何人都可以帮助我吗?
谢谢,