WCF服务器控制客户端(Windows窗体)
我正在构建一个应用程序,这很简单,我想做的是以下内容。我想要一个无脑的客户端,所有的工作都应该在服务器上完成。所以我想要一种方法来更改我的服务器应用程序中的窗口窗体,而不是在客户端本身。
因此,当我有像二十一点这样的应用程序时,用户按下击中键,然后调用服务器上的击中函数,他将计算所有内容,将结果发送回客户端,然后客户端更新它的按钮和 GUI(例如显示牌) ,等等)。
现在如何在 WCF 中执行此操作?我知道如何调用远程函数,但我无法让 Windows 窗体部分工作(我可以在合同中添加它吗?如何添加?)
谢谢!
I'm building an application, it's easy and what I want to do is the following. I want a brainless client and all the work should be done on the server. So I want a way to change windows forms in my server application and not on the client itself.
So when I have an application like blackjack the user presses hit then the hit function on the server get called, he will calculate everything, send the result back to the client and then the client updates it buttons and GUI (like displaying cards, and so on).
Now how do you do this in WCF? I know how to call remote function but I can't get the windows forms part to work (can I add this in the contract, and how?)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的客户端应该处理它自己的所有 UI。您的服务不应该与用户界面有任何关系。
无需让服务处理 UI,只需让它将消息发送回客户端,并让客户端根据消息确定要显示或不显示哪些 UI 元素。
因此,当服务器计算出某些结果(例如 BLACKJACK!)时,它会向客户端发送一条指示该结果的消息,然后客户端将显示正确的 UI 元素。
有道理吗?
Your client should handle all of its own UI. Your service shouldn't have anything to do with the UI.
Instead of having the service handle the UI, just have it send messages back to the client and let the client figure out which UI elements to show or not based on the messages.
So, when the server calculates some result, like BLACKJACK!, it'll send a message indicating that back to the client which will then show the proper UI elements.
Make sense?