Signalr SinglR通知不显示MVC
我正在训练如何在数据库发生更改时发送通知,但什么也没发生我刚刚启动了他的控制台浏览器通知中心 NotificationHub.csSignalr SinglR通知不显示MVC,signalr,Signalr,我正在训练如何在数据库发生更改时发送通知,但什么也没发生我刚刚启动了他的控制台浏览器通知中心 NotificationHub.cs public class NotificationHub : Hub { //public void Hello() //{ // Clients.All.hello(); //} } NotificationComponent.cs void sqlDep_OnChange(object sender, Sq
public class NotificationHub : Hub
{
//public void Hello()
//{
// Clients.All.hello();
//}
}
NotificationComponent.cs
void sqlDep_OnChange(object sender, SqlNotificationEventArgs e)
{
if (e.Type == SqlNotificationType.Change)
{
SqlDependency sqlDep = sender as SqlDependency;
sqlDep.OnChange -= sqlDep_OnChange;
var notificationHub = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>();
notificationHub.Clients.All.notify("added");
RegisterNotification(DateTime.Now);
}
}
public List<Activity> GetContacts(DateTime afterDate)
{
using (DataBaseTabelModel dc = new DataBaseTabelModel())
{
return dc.Activities.Where(a => a.Date > afterDate).OrderByDescending(a => a.Date).ToList();
}
}
var notificationHub = $.connection.notificationHub;
$.connection.hub.start().done(function () {
console.log('Notification hub started');
});
notificationHub.client.notify = function (message) {
if (message && message.toLowerCase() == "added") {
updateNotificationCount();
}
}