【发布时间】:2018-12-25 07:29:11
【问题描述】:
谁能分享描述如何以正确方式使用 IHubContext 的链接?因为我只是混淆了如果我可以直接从控制器发送消息,我的 NotificationHub 的目的是什么?
public class NotificationHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
我从控制器调用的内容:
await hubContext.Clients.Client(user.Id.ToString()).SendAsync("ReceiveMessage", user.FirstName);
IHubContext<NotificationHub> 类型的 hubcontext
从控制器发送消息的正确方法是什么?
【问题讨论】:
标签: .net asp.net-core .net-core signalr asp.net-core-signalr