- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
来自 here ,它指出
All clients will use the same URL to establish a SignalR connection with your service ("/signalr" or your custom URL if you specified one), and that connection is used for all Hubs defined by the service.
There is no performance difference for multiple Hubs compared to defining all Hub functionality in a single class.
最佳答案
由于 SignalR 已集成在 ASP.NET Core 中,因此无法实现 any more为多个集线器使用一个连接:
In ASP.NET Core SignalR, the connection model has been simplified. Connections are made directly to a single hub, rather than a single connection being used to share access to multiple hubs.
#region
如果您想使用单个集线器,则用于构建您的代码。
ChatHub
) 进行聊天。如果我也有测验系统,我会使用
QuizHub
, 等等...
IHubContext<T>
在该 Controller 中使用一些 SignalR 功能。 .
In ASP.NET Core SignalR, you can access an instance of IHubContext via dependency injection. You can inject an instance of IHubContext into a controller, middleware, or other DI service. Use the instance to send messages to clients.
class SomeController : Controller
{
private readonly IHubContext<MyHub> _hubContext;
public SomeController(IHubContext<MyHub> hubContext)
{
_hubContext = hubContext;
}
}
关于c# - 多集线器一连,防止神级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53866190/
我是一名优秀的程序员,十分优秀!