architecture/multiple "worlds" management

My project is built around several “arena” servers that are being run on the same machine and are completely independant game worlds. What I would like to do is have a central arenas server that is always running. When an arena is brought online, it contacts the central server and lets it know its name, port, and perhaps some information about the arena. Then periodically the central server will query all registered arenas to ensure they are still available and update any stats that are pertinent. If the arena closes, it will notify the central server to remove it from the active list and if it does not respond to the central server’s periodic request for an update, it will also be removed (and maybe an admin will be sent an email or something).

Could anyone point me to an article or tutorial regarding this sort of communication between applications? I have only the roughest idea of how to proceed…

take a look at the source code in the planetation.jar file in this zip.

http://www.scottshaver2000.com/planetation/files/planetation.zip

Look specifically at the UniverseServer.java and WorldServer.java files and the associated config files for them (also in the zip) .

This is exactly what you are trying to do, I’m not saying it is the best way but it is how I did it. These are bare bones implementations so there isn’t a load of other code to dig through to see what they are doing.

I bookmarked planetation on my old PC, but I had forgotten where I found the link originally. Thanks for the example code, it’s just the right level of bare-bones-ness to be useful ;D

Cool. Just a side note you will see that the system is set up to allow any data/command to be sent between machines. I am curently having to do a lot of rework because I didn’t add a version number to the CommunicationData class. When you implement your stuff make sure to add a version number to any data you are send back and forth. This way you can deal with changes in data formats dynamically.

I’ve got something up and running pretty well right now. My next question is whether you have any advice on centralized player registration. What I’ve just added is a central Universe server, so clients connect first to this server and it sends them a list of all arenas that are currently online and some basic stats about each one. A user then selects a particular arena and opens up a session directly with that arena.
What I’m interested in doing is creating only one session to the Universe server, which would validate a user’s credentials or have them create a new account if this is their first time playing. Once they are validated, the Universe server would pass their session to one of the arena servers and they would enter the game. Is there any way to accomplish this and make it transparent to the user? My design is based on arenas running independently, with their own ports open to receive clients. I am hoping this is possible without a major rewrite…

I think your fine You give the client the arena server info it needs to connect to it and just have the client automatically do this. No need for the user to interact with this process. You can’t trade socket connections from the universe server to the arena server though. This is a totaly separte connection.

But how would I know that the Universe server authenticated the client?

How about generating a key, sending it to the arena, letting it know about an incoming connection. Once the Arena confirms receipt of the key, send the key to the client. Client connects to arena, keys match, all is well. Assuming there is a problem, the arena key times out after, say 1 min.

Hey that’s a great idea.

It would be cool if the arena could connect to the client but the clients would all have to have static IPs which wouldn’t work for most people.

[quote]But how would I know that the Universe server authenticated the client?
[/quote]
Lefty described something very similar to Kerberos which is supported by the 1.4 JVM and can be downloaded as an option package for the 1.3 JVM.

I would suggest looking into the Object Replication design pattern as laid out in M. Grands Java Enterprise Design Patterns. Unless you need the worlds absolutely in sync 100% of the time (which will be a HUGE problem), this pattern and a caching strategy will keep all the worlds in sync. I recommend the book - I’ve talked with the author and took his Design Patterns course… he knows his stuff and it has a direct impact on what you’re planning to do.