.NET Remoting - 服务器如何更新客户端?
现在,我正处于原型设计阶段。 所以我才刚刚开始。
情况: 服务器 - 将运行测试并向客户端发布进度,影响必须低,无网络服务器,可能运行 xp 嵌入式或 xp home。
客户 - 启动测试并接收进度报告。 运行xp专业版。
两台机器通过以太网连接。 我想使用 .NET 远程处理在两台计算机之间进行通信,并且我想使用事件来使用服务器的新结果更新客户端,但我了解到事件在这些条件下是不可靠的。 我该怎么做? 服务器可以连接到客户端并使用远程处理来发布事件吗? 这样可以吗?
Right now, I am in prototyping phase. So I am just getting started.
Situation:
Server - Will be run tests and publish progress to Client, must be low impact, no webserver, possibly running xp embedded or xp home.
Client - Initiate tests and receive progress report. running xp pro.
The two machines are connected via ethernet. I would like to use .NET remoting to communicate between the two machines, and I would like to use events to update the client with new results from the server, but I've read that events are unreliable in these conditions. How should I do this? Could the Server connect to the client and use remoting to publish the events? Would that work okay?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我曾经部署了一个使用远程处理的系统,服务器启动了一些客户端可以订阅的事件。
为了使其成为可能,您必须将 typeFilterLevel 设置为 full,并且还必须创建一个客户端和服务器上已知的“中间”对象,以便能够处理您的事件。
例如:
这是服务器上已知的类 在客户端。
在客户端,您创建另一个类,该类继承上述类,并实现引发事件时必须执行的实际逻辑。
您只需将事件处理程序附加到远程对象的事件,如下所示:
当然,如果您更新 EventHandler 类中的 Winform 控件,该类也应该实现 ISynchronizeInvoke。
I once deployed a system wich used remoting, and where the server launched some events to which the client could subscribe to.
In order to make it possible, you have to set the typeFilterLevel to full, and, you also have to create an 'intermediate' object that is known on the client and on the server in order to be able to handle your events.
For instance:
This is the class that is known on the server & on the client side.
At the client-side, you create another class which inherits from the above class, and implements the actual logic that must be performed when the event is raised.
You simply attach the eventhandler to the event of the remote object like this:
Offcourse, if you update Winform controls in your EventHandler class, that class should also implement ISynchronizeInvoke.
通过服务器连接到客户端,您实际上颠倒了模型并使服务器成为客户端,反之亦然。
您最好让客户端启动测试,并轮询服务器以获取状态更新。
您选择的远程处理并不是什么大问题(并且对我提供的意见没有影响),但您可能想研究其替代品(WCF),而不是花时间在“已替代但仍受支持”的技术上。
By the Server connecting to the client, you are actually inverting the model and causing the server to become the client and vice versa.
You are better off having the client initiate tests, and poll the server for status updates.
Your choice of remoting is not really a big deal (and makes no impact on the opinion I offered), but you may want to investigate its replacement (WCF) instead of spending time on a 'replaced but still supported' technology.
由于您仍处于原型设计阶段,因此您可能需要考虑使用 Windows Communication Foundation (WCF) 而不是远程处理。 WCF 内置了对发布-订阅方案的支持,并且已经包含 .NET 远程处理和 Web 服务的所有功能(据我所知)。
Since you're still in the prototyping stage, you might want to consider using Windows Communication Foundation (WCF) rather than remoting. WCF has built-in support for publish-subscribe scenarios, and already contains all the functionality of .NET remoting and web services (from what I understand).