【发布时间】:2019-09-26 13:25:24
【问题描述】:
我创建了一个与 signalR 一起使用的通知系统,还创建了一个在添加通知后立即发生的事件。我想从同一事件中调用我的notifictionHub 中的函数我已经看到一些对我正在使用的版本无效的解决方案,我想知道我该怎么做?
通知中心:
public async Task SendNotification(string user, string content)
{
string userID = "3";
foreach(var cid in _connections.GetConnections(userID))
{
await Clients.Client(cid).SendAsync("ReceiveNotification", user, content);
}
}
添加通知事件:
private static void Notifications_OnNotificationAdd(Account account, Notification notification)
{
// call NotificationHub->SendNotification from here...
}
【问题讨论】:
标签: asp.net .net .net-core notifications signalr