0

i'm not a newbie in Java programming. I would like to know how can i proceed with my project.

I want to develop a centralized gaming system in Java using TCP/IP protocol socket system. It should get the player details and display the information in the gaming window.

These are my criterias:

Maximum & Minimum number of players can participate?? The behavior of the server in front of a given state of the game board: should invite one or more players to offer their shots, notify the blow of an opponent or a player can declare the party over? How to update the game when a shot is provided by a player???

I'm not looking for a straight answere here. I'm looking for some guidence which would be helpful for me to start with the project. Is there are any tools for Multi-client multi instance centralised server using TCP protocol???

4

2 回答 2

1

首先是网络层

有几个用于 java、mina、netty 的网络库。

借助这些网络库,您可以轻松解决网络问题。

和逻辑层

您应该维护user_context服务器内存中的所有对象,并将每个对象绑定到相应的 tcp 连接。在大多数情况下,user_context对象维护为 RB-tree 的 hashmap/dictionary。

因此,当某些事件发生时,您可以找到相应的用户/客户端并将消息发送给他们。

于 2012-03-25T04:12:32.603 回答
1

我认为最小的玩家人数是 0;

最大值可能取决于;- 你的带宽,你需要有一个显着的上传速度,你想要成千上万的用户。- 管理每个用户需要做多少工作。你可以在一台服务器上连接到 10,000 个用户,如果他们做的不多,但是当你添加功能时,每台服务器的用户数将下降到 1000 个,可能只有 100 个。

当您拥有无限带宽和每个连接的琐碎工作(通常byte[]是零复制)时,IO 框架的选择会产生很大的不同。对于实际应用程序,它不太重要。如果您以后找到更好的解决方案,我建议您选择的任何解决方案都可以轻松更换。

有没有使用 TCP 协议的多客户端多实例集中服务器的工具???

一种常用的工具是 JMS,但游戏可能是您可能不会使用它的一个领域。我会从 ActiveMQ 开始,因为这会让你快速启动并运行,只要确保你以后可以轻松替换它。

于 2012-03-25T08:34:27.360 回答