[英]Getting the context from a different assembly
In my project I have different assemblies. 在我的项目中,我有不同的程序集。
The SignalR hub (and client MVC4 files) live in the Website
project. SignalR集线器(和客户端MVC4文件)位于
Website
项目中。
My hub looks like this: 我的中心看起来像这样:
public class PredictHub : Hub
{
private readonly IChat _chat;
public PredictHub(IChat chat)
{
_chat = chat;
}
public void Chat(String message)
{
_chat.AddMessage(message);
}
}
In my second assembly Business
the IChat.cs
and Chat.cs
live: 在我的第二个组装
Business
的IChat.cs
和Chat.cs
生活:
public class Chat : IChat
{
public void AddMessage(String message)
{
var context = GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
}
}
But because Chat.cs
is in the Business
assembly the ChatHub
directive is not known because it's not referenced. 但是因为
Chat.cs
在Business
程序ChatHub
所以不知道ChatHub
指令,因为它没有被引用。
How could this be solved? 如何解决呢?
仅当SignalR和Chat类处于同一过程中时,才能获取上下文。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.