将SingalR与非MVC应用程序一起使用 [英] Using SingalR with non MVC application

查看:90
本文介绍了将SingalR与非MVC应用程序一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我已经在互联网上做了很多搜索,找到了一个没有运气实现SingalR的非MVC应用程序的例子。

好​​的简要介绍一下我的情况之后。

我想使用SingalR在任务完成时向用户显示弹出消息,我在数据库中有一个名为notification的表,其中有一个statusId列,我希望Singalr呈现一个当此状态设置为某个值时弹出。显示弹出窗口不是使用SingalR知道数据库中何时达到此值的问题。

关于如何实现这个或者甚至是可能的任何想法?

我正在使用Sql Server,先谢谢你们。

Hey guys, I''ve done a lot of searching on the internet to find an example of a non MVC application which implements SingalR with no luck.
Ok a brief overview of what I am after.
I want to use SingalR to present the user with a popup message when a task has completed, I have a table in the database called notification which has a statusId column, I want Singalr to present a popup when this status is set to a certain value. Displaying the popup is not the problem its using SingalR to know when this value is reached in the database.
Any ideas on how to achieve this or is it even possible?
I''m using Sql Server thanks in advance guys.

推荐答案

我没有和SignalR一起玩过这么多,我用它做的很少,主要集中在Hubs上。从我所看到的,从集线器调用客户端函数导致该函数被自动生成到客户端引用的jQuery中。



创建的自动生成的函数与我们在任何基于WinForms或WPF的应用程序中使用的事件非常相似。通过这个,我的意思是,客户端有一个事件处理程序(即你的弹出代码),他们注册到一个事件。一旦引发事件(从集线器/服务器调用客户端函数),就会调用客户端的事件处理程序。



听起来你需要一个在服务器端调用正确客户端的方法。
I haven''t played around all that much with SignalR and the little that I did use it was mostly focused on Hubs. From what I saw, calling a client function from the hub results in that function being auto-generated into jQuery that''s referenced by the client.

The auto-generated functions that are created act a lot like events we use in any WinForms or WPF based application. By this, I mean, that the client has an event handler (i.e. your pop-up code) that they register to an event. Once you raise the event (call the client function from the hub/server), you client''s event handler will be called.

It sounds like you need a method on the server side that calls the correct client(s) at the correct time.


这篇关于将SingalR与非MVC应用程序一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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