Java Lobby for Multiplayer Memory game

I have created a client/server Java Multiplayer Memory Game. One game can have 4 players. Each player has its own thread which sends/receives game info via a socket. My problem is I would like to add a lobby area that hosts an unlimited number of rooms which contain my memory game. How would I go about making this kind of lobby? Would the lobby just handle the clients connection IDs and spawn a thread for each memory game room. ? Is there any good books about creating multiplayer game lobbies? Or good examples and source??

Any info you can give would be greatly appreciated.

A big question is how scalable you want this to be?

A lobby that handles a few dozen players at a time is realtively easy. One that handles thousand is a much more complex project.

Second question is, what are your hosting resources? Can you run a server to run this lobby yourself at a well known IP or DNS name? If not, then you need to think in terms of what you can get a hosting service to run for you, which probably means a J2EE based design.

Third question, relating to the second, is how mission critical is this?: Can you afford for your lobby server to be down for significant amounts of time? If not then you probably dont want to run it yourself even if you could (see the second point above.)

Last question, is how important is it to you to be able to traverse firewalls? Is this game latency critical or can you afford longer latencies? Based on these answers you are going to chose a communication strategy.

I hope that I understood what you said. (because my english skills are limited :wink: )

I wrote a PHP script server and a corresponding java class that enable multiple applets and/or applications to communicate.

PHP script is a standard PHP script. Java classes use HTTP port and should work for unsigned applet even through firewalls and proxies.

Java class enable you to open / close a channel, write / read binary packets(char,int,String,etc…) and to send it to the server (PHP script), you can also request to receive all other user packets sent to the same channel.

Server use files and directories as database, and there is no need to install a real database. Server should work with any standard web hosting server.

I have tested it on a dedicated server and it’s able to make real-time transactions (<20ms for local), but, with standard web hosting, you will have transaction latency up to 2 seconds!

Let me know if it could be a good solution for you, and I will send you source code (working but not yet finished and a bit dirty)?

Bruno

Thats okay Bruno, I think i understand your situation better now. (Your English is fine. I’m curious what your first language is though. I speak a tiny bit of Italian, but its limited and very rusty. I lived for a year in Milano about 20 years ago.)

The short answer is that you can use the same kind of system for your lobby as you are for your game.
Thinking of is this way might help: A lobby is just a database of game sessions. A game session creator puts a record up to the database describing the session and the game joiners select one of the games to join, at which point they retrieve the record describing the session from the database.

A secondary issue is chat. If you want chat there are a few ways to accomplish it. You could do it through the same HTTP based system you have now. In that case each player chatting puts his lien of chat up to the server and periodically polls the server to get any liens put up by other players.

Alternately, you could just piggyback your chat on the existing IRC network.

All this should work for a game that doesn’t have too large a number of simultaneous players. I suspect your entire infrastructure is likely to run into scaling problems (including your current server design) if you start getting a huge number of players.

My first language is french : I learned english at school and spent 2 months in australia (10 years ago) and 2 month in USA (18 years ago). It is not enough to learn :wink: )

Bruno

Jeff, thnx for the reply. Im a little confused…Sorry.

The short answer is that you can use the same kind of system for your lobby as you are for your game.
Thinking of is this way might help: A lobby is just a database of game sessions. A game session creator puts a record up to the database describing the session and the game joiners select one of the games to join, at which point they retrieve the record describing the session from the database.
Game session? How would you go about implementing the above? Any source code or psuedocode? Any resources that could point me in right direction?

All this should work for a game that doesn’t have too large a number of simultaneous players. I suspect your entire infrastructure is likely to run into scaling problems (including your current server design) if you start getting a huge number of players.
Why do you think there will be problems with large number of players. I want my memmory game to have unlimited number of players…How would correct?

A game sesson is just one group of players playing a game.

If you start counter strike and “create a game” what youa e really doing is creating a session. FOllow?