来自多个数据库的SignalR中的推送通知 [英] Push Notifications in SignalR from multiple Databases

查看:79
本文介绍了来自多个数据库的SignalR中的推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对SignalR还是比较陌生,到目前为止,我所做的是在其上开始使用示例聊天应用程序.

I am relatively new to SignalR, What I have done so far are example chat applications on it to get started.

我们有一个包含多个数据库的项目,这是一个机器数据收集应用程序.我已经在ASP.NET MVC中创建了一个Web控件,以便在一处查看多台计算机的数据.

We have a project that includes multiple databases, it's a machine data collection app. I have created a web control in ASP.NET MVC to view data of multiple machines at one place.

我们有多个用户,他们可以访问与其项目相关的计算机.当前的解决方案在mvc页面上有一个jQuery观察器,可在特定时间刷新机器控件.

We have multiple users and they can access machines related to their projects. The current solution have a jQuery observer on the mvc page which refreshes the machine controls in a specific time.

我正在考虑使其成为推送通知解决方案.但是,由于我是SignalR的初学者,所以我不知道该如何处理.

I am thinking of making it a Push Notification solution. But as I am a beginner on SignalR I don't know how to approach this.

目标是通知用户有关用户有权访问的计算机(并非所有计算机)的数据更改.

The goal is to notify the user of changes in data for machines that the user has access to (Not all machines).

我又如何将消息从数据库服务器发送到SignalR,以通知数据更改?

Also how can I send messages from a database server to SignalR notifying of changes in the data?

我需要一些入门指南.

推荐答案

SignalR Send 方法允许您将数据发送给用户!它可以使用推送,框架,服务器事件或Websocket技术.您的开发人员不在乎该技术!这取决于服务器和客户端的握手.

SignalR Send method allows you to send data to user! It may use push, frame, server events or websocket techniques. You developer don't care about the technique! It depends on server and client handshake.

您真正需要的是从数据库中检索数据,然后毫无疑问地将数据提供给用户

What you really need is to retrieve data from your databases and then to users, without worries

 // Server side: 
protected override Task OnConnected(IRequest request,  
                                 string connectionId) 
{ 
    var db = new allEntities();
    var db2 =new allEntities2();
    var data1 = db.Tables.Where(e=>e.LastUpdate<=datetime.now.AddDays(-1));
    var data2=db2.Tables.Where(e=>e.Something==someRef);
    var data=combine(data1,data2);//combine logic goes here
    return Connection.Send(connectionId, data.ToList()); 
}

这篇关于来自多个数据库的SignalR中的推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆