English 中文(简体)
Java-如何撰写游说游戏服务器
原标题:Java- How to write a lobby game server
  • 时间:2011-10-31 01:20:06
  •  标签:
  • java

因此,我撰写一部根据游说团对赌博室、一般聊天等进行对比的制度。 迄今为止,我有一个工作原型,但我对我与服务器做的一些事情有很大怀疑。 撰写一夫一妻的游说服务器是我新的方案拟订经验,因此我没有清晰和准确的方案拟订模式。 我也找不到一份描述它应如何工作的文件。 我从亚马孙订购了“Java网络第3版”并仍在等待装运,希望我在本书中找到一些有用的实例/信息。

与此同时,我要收集你的意见,看你将如何处理某些事项,以便我能够了解如何正确书写服务器。 下面是我头顶上的几个问题:(也许会有更多的机会)

First, let s define what a server does. It s primary functionality is to hold TCP connections with clients, listen to the events they generate and dispatch them to the other players. But is there more to it than that?

我是否应该对每个客户使用一对一对read? 如果是的话,300名客户=300read。 难道没有这么多? 需要哪些硬件来支持这一点? 游说团消费的带宽多多少?

What kind of data structure should be used to hold the clients sockets? How do you protect it from concurrent modification (eg. a player enters or exists the lobby) when iterating through it to dispatch an event without hurting throughput? Is ConcurrentHashMap the correct answer here, or are there some techniques I should know?

当用户进入大厅时,你会利用何种机制将游说状态移交给他? 虽然这种情况正在发生,但其他事件在哪些地方都令人不安?

非常感谢投入。 感谢!

http://goo.gl/pYqM3”rel=“nofollow”

问题回答

值得注意的第一件事是:there不是单一的正确答案。 有100万种不同和完全有效的办法可以推广类似的东西。

你重新思考你设计工作的各个方面,这是好事,但认识到,试图就你设计前线做太多事情,将会使你放慢,并可能不会导致最佳设计。 原因是,在你打上<>号”之前,你不会再知道你会遇到什么问题。

如果你从头脑中重新这样做,我强烈建议使用,以试验驱动的发展,采用这一方法设计软件:

  1. Pick a small feature to implement next
  2. Write a failing test case that will pass only when the feature is correctly implemented
  3. Write the minimum amount of code possible to make the test pass
  4. Go to step 1

废除所有新法典,确保你尽快遇到问题。 最后,你还进行了一套自动测试,确保你在任何时间都有一个工作系统。

在对几个周期适用后,你已经看到设计开始出现。 在短周期中这样做,也使你有机会经常评估下一个最重要的特征,而不是对非进口特征的细节进行断断断断断断断断。

有大量文献介绍TDD。 我建议检查其中的一些内容:





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签