简体   繁体   English

通知客户更新的最佳方式?

[英]Best way to notify clients for an update?

Ok, on the server side there's a desktop application which is used to insert some information into a database (news,images,ect..) and i have clients which gather this information from database and store them into their local XML . 好的,在服务器端有一个桌面应用程序,用于将一些信息插入数据库(新闻,图像等),我有客户端从数据库收集这些信息并将它们存储到本地XML中。

So each client downloads news from database and displays them . 因此,每个客户端从数据库下载新闻并显示它们。

The issue is how I can notify clients that there is an update . 问题是我如何通知客户有更新。

My Solution 我的解决方案

I thought using a database filed like UpdateID ,and on each data update into database UpdateID should be Incremented +1, then every client should have an attribute UpdateID into their XML, and check if their UpdateID matches the Server UpdateID, if not than this is a new update. 我想使用像UpdateID这样的数据库,并且每次数据更新到数据库UpdateID都应该是Incremented +1,然后每个客户端都应该在其XML中有一个属性UpdateID,并检查他们的UpdateID是否与Server UpdateID匹配,如果不是这样的话一个新的更新。 On each successful update, clients should place server UpdateID into their XML UpdateID . 在每次成功更新时,客户端都应将服务器UpdateID放入其XML UpdateID中。

So is there any better way to achieve that ? 那么有没有更好的方法来实现这一目标?

PS : The Data Re-present layer which im using is a WCF Service PS:我正在使用的数据重新呈现层是WCF服务

I think that the pull model that you propose is probably the easiest to implement and most straightforward solution to the problem. 我认为你提出的拉模型可能是最容易实现的,也是最简单的问题解决方案。 Knowing that you are using WCF webservices, however, you have the possibility to implement a push model using WCF Callbacks . 但是,知道您正在使用WCF Web服务,您可以使用WCF Callbacks实现推送模型。 In this model you write service contracts just as normal but here the clients register themselves on the server. 在这个模型中,您可以像平常一样编写服务合同,但客户端在服务器上注册自己。 On data updates on the server the server calls a callback function on all registered clients, which respond by fetching new data. 在服务器上的数据更新时,服务器在所有已注册的客户端上调用回调函数,该客户端通过获取新数据进行响应。

The typical showcase application for this model is a ticketing system, where tickets are booked and released often. 该模型的典型展示应用是票务系统,票据经常被预订和发布。 This approach eliminates the need for clients to constantly poll the server. 这种方法消除了客户端不断轮询服务器的需要。

The article called Eliminate Server Polling with WCF Callbacks gives more details on the subject and also comes with a ticketing system example. 名为“ 使用WCF回调消除服务器轮询 ”的文章提供了有关该主题的更多详细信息,并附带了票证系统示例。 This article also describes this method. 本文还介绍了此方法。

I am not saying that this is better than what you suggest yourself, but it may be worth looking into. 我并不是说这比你自己建议的更好,但它可能值得研究。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM