简体   繁体   English

Windows窗体和WCF-客户端应用程序通信

[英]Windows Forms & WCF - Client Application Communication

We are developing a Windows Forms application that will be installed on about 1,000 employee pcs. 我们正在开发Windows窗体应用程序,该应用程序将安装在约1,000名员工的PC上。 Users may run multiple instances of the application at the same time. 用户可以同时运行该应用程序的多个实例。 The clients are all on a single intranet. 客户端全部在单个Intranet上。

Changes in the application may cause database record changes, which in turn must be communicated to the other clients so their UIs are updated. 应用程序中的更改可能导致数据库记录更改,而数据库记录更改又必须传达给其他客户端,以便更新其UI。

Our team has talked about two different approaches: 我们的团队讨论了两种不同的方法:

1. Multicast packets 1.组播数据包

The source client modifies the records and then sends out a multicast packet with a payload that something has changed. 源客户端修改记录,然后发送带有某些已更改有效负载的多播数据包。 The other clients receive this and fetch the data specified. 其他客户端收到此消息并获取指定的数据。 We need to account for the cases when the packet is not received, falling back onto actively retrieving the data. 我们需要考虑未接收到数据包的情况,然后退回主动检索数据。

My question at this point is how does a client know it didn't receive a packet? 我现在的问题是客户如何知道它没有收到数据包? (don't know what you don't know) Which brings us to some sort of event log with timestamps in the database, and UI controls track the last time they were updated. (不知道您不知道什么)这使我们进入了带有数据库时间戳的某种事件日志,UI控件跟踪了它们的上次更新时间。 They come into focus, check their timestamps, and update as needed. 他们开始关注,检查其时间戳,并根据需要进行更新。

Someone else said the UI elements would just reload every time they come into focus (think modes in outlook, bringing controls to the front of a stack workspace with CAB). 有人说,UI元素每次聚焦时都会重新加载(考虑一下Outlook中的模式,将控件放置在带有CAB的堆栈工作区的前面)。 And that the multicast is to update the clients that their current context has changed. 并且多播将更新客户端其当前上下文已更改。 If they miss it they work with stale data until they change modes and come back. 如果他们错过了,他们将使用过时的数据,直到他们更改模式并返回。

2. WCF and Callbacks 2. WCF和回调

Clients register with WCF contracts for callbacks over a tcp binding. 客户端向WCF合约注册以通过tcp绑定进行回调。 The primary technical concern with this is the server maintaining many open sockets. 与此相关的主要技术问题是服务器维护许多打开的套接字。 We have read up on how it isn't open in the traditional sense, it is put to sleep for a maximum of 90 seconds and then re-established at that point. 我们已经阅读了传统意义上的未打开方式,将其置于睡眠状态最多90秒钟,然后在该位置重新建立。 We also read about the maximum number of open connections a Windows 2003 Server machine can handle, and how to modify that in the registry. 我们还了解了Windows 2003 Server计算机可以处理的最大打开连接数,以及如何在注册表中进行修改。

If we have 1,000 open socket connections to a server is this going to fall apart? 如果我们有与服务器的1000个开放套接字连接,这会崩溃吗?

If anyone has faced this same situation and tried or evaluated the WCF approach we would love to hear about it. 如果有人遇到过同样的情况并尝试或评估了WCF方法,我们将很乐意听到。

I have not implemented a situation like this. 我没有实现这种情况。 However, I would think that one of the duplex bindings would not necessarily have a high overhead. 但是,我认为双工绑定之一并不一定会有很高的开销。

It all depends on how much information the server needs to send back to the clients. 这完全取决于服务器需要将多少信息发送回客户端。 I understand you said the information will be used for them to update their UI. 我了解您说这些信息将用于他们更新其UI。 However it seems possible that they may not all need the same amount of information at the same time. 但是,似乎他们可能并非全部同时需要相同数量的信息。 For instance, if information about the Western region has changed, all 1000 clients may want to know that there is a change, and they may all want to update summary-level information about the Western region, but perhaps only 1/4 of them may need to see the details of the change. 例如,如果有关西部地区的信息已更改,则所有1000个客户端可能都想知道有一个更改,并且他们都可能希望更新有关西部地区的摘要级别的信息,但也许只有1/4的客户可能会知道需要查看更改的详细信息。

If this is the case, then I'd recommend that the callback only provide information about what has changed, mostly at a summary level. 如果是这样的话,那么我建议回调仅提供有关发生什么变化,主要是在一决高低的信息。 Let those clients who are interested in the details of the change ask for the details. 让那些对更改的详细信息感兴趣的客户要求提供详细信息。 You might even go as far as to provide all the details for the top one or two levels of hierarchy, then for the rest, just include information saying "this changed at time ". 您甚至可以提供最高的一到两个层次结构的所有详细信息,然后为其余的信息仅提供说“这在时间上有所变化”的信息。 That way, depending on the level of hierarchy being viewed by a particular client, the client could then ask or not ask. 这样,根据特定客户端正在查看的层次结构级别,客户端可以随后询问或不询问。

If necessary, you could batch updates together. 如有必要,您可以一起批量更新。 If the clients only need to be updated once per second, then you could accumulate the changes for the last second and send them all at once. 如果客户端仅需要每秒更新一次,那么您可以累积最后一秒钟的更改,然后一次发送所有更改。

You may also want to use some of the Peer to Peer bindings for some tasks. 您可能还需要将一些对等绑定用于某些任务。 Perhaps the clients in a particular area of your business would like to know a little about what each other are working on - that sort of thing. 也许您业务中特定领域的客户希望了解彼此正在做些什么-这种事情。

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

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