德州扑克中的客户端/服务器通信
我目前正在用 Java 编写德州扑克 LAN 游戏。我的问题是如何进行客户端/服务器通信。
每次餐桌上发生事情时,都需要通知客户,以便他们可以重新绘制 GUI。此外,当玩家轮到时,他们需要能够弃牌、跟注等。
我如何最好地实现这一点?我研究过回调/RMI,但从我读到的内容来看,这可能会导致防火墙出现问题(?)
I am currently programming a Texas Hold'em LAN game in Java. My problem is how to do the client/server-communication.
Each time something happens at the table, the clients need to be informed of this so they can repaint their GUIs. Also when a players turn is up, they need to be able to fold, call etc.
How do I best implement this? I've looked at callbacks/RMI, but from what I've read, that may cause problems with firewalls(?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您担心防火墙时,最好的方法是使用 HTTP,就像 Web 浏览器一样。好处是:
缺点是服务器推送消息并不常用。当然,您可以只从每个客户端打开一个 HTTP 连接,等待来自服务器的数据。
When you are concerned about firewalls, the best way would be to use HTTP, like a web browser. The benefits are:
The downside is that push messages by the server are not commonly used. Of course you can just open an HTTP connection from each client that will wait for data from the server.
我建议有关套接字的 Java 教程:
http://download.oracle.com/javase /tutorial/networking/sockets/
给出了一个客户端/服务器示例。
I would suggest the Java tutorials on sockets:
http://download.oracle.com/javase/tutorial/networking/sockets/
An example client/server is given.