客户端(桌面应用程序)拉数据......但我希望服务器(网络应用程序)推送数据 [英] The client (desktop app) pulls data...but I want the server (web app) to push data

查看:23
本文介绍了客户端(桌面应用程序)拉数据......但我希望服务器(网络应用程序)推送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户端-服务器应用程序 - 其中服务器本质上是一个 ASP .NET Web 应用程序,而分布式客户端是桌面应用程序.

I have a client-server application - wherein the server is essentially an ASP .NET web application and the distributed clients are desktop applications.

客户端需要从服务器接收一些数据 - 当客户端有新数据时.现在,这样做的方式是 - 客户端每 x 分钟(比如 2 分钟)不断查询 Web 服务,并不断检查是否有客户端的新数据.

The clients need to receive some data from the server - when there is new data for the client. Right now, the way this is done is - the client keeps querying a web service every x minutes (say 2 minutes) and keeps checking if there's new data for the client.

理想情况下,它应该工作的方式是桌面应用程序应该在更新可用时接收更新,它不需要从服务器拉取;相反,服务器应该能够推送到客户端.

Ideally, the way it should work is that the desktop app should receive updates as and when they are available, it need not pull from the server; instead the server should be able to push to the client.

根据解决方案的架构,我该如何着手执行此操作?Web 应用程序需要将数据推送到同一网络(LAN)中的桌面应用程序(客户端)?

How do I go about doing this - given the architecture of the solution - a web application needs to push data to desktop applications (clients) in the same network (a LAN)?

推荐答案

您所描述的是服务器推送",现在通常称为COMET".在网络搜索中使用这些关键字应该会找到很多有用的信息.

What you're describing is "server push", which these days is often called "COMET". Using those keywords in a web search should turn up a lot of useful information.

最常用的技术称为挂起 GET".客户端向特定 URL 发送 GET 请求,服务器接受连接但延迟发送响应,直到它有数据要发送.当客户端收到响应时,它会发送另一个 GET,以便为另一条消息做好准备.

The most common technique for this is called a "hanging GET". The client sends a GET request to a specific URL, and the server accepts the connection but delays sending a response until it has data to send. When the client receives the response it sends another GET so it's ready for another message.

这篇关于客户端(桌面应用程序)拉数据......但我希望服务器(网络应用程序)推送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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