Hey all, I have a design question about how to set up a feasible 8-player game using a client-server model. The game is very simple (a bomberman remake, actually). The only things the clients will be sending to each other are:
- chat messages
- change in X,Y sprite location
- placing of a bomb at X,Y location
- picking up of powerup at X,Y location
and maybe a few more things, but that’s about it. all of the “events” could be represented by simple strings, since the client will do all of the message processing (if the client receives a message that says “NEW BOMB, player1, 4, 5”, it will create a new bomb object for player1 at location 4, 5. etc etc. So, keeping that in mind, will the following server model work?
the server would do the following:
– start server
– create thread that checks for new connections
– if new connection X, create 2 new threads to handle X: a receiveMessage thread and sendMessage thread
the two threads for each client would do the following:
the receiveMessage thread will continuously check for a new message over connectionX’s socket. If a message is recieved, the message is added onto the “toSend” queue of every other connection.
the sendMessage thread will continuously check the “toSend” queue to see if there are any items in it. If there are any items to send, it will remove an item and send it to the player. The “toSend” queue of each player will obviously be synchronized to protect it’s data.
My question is: will this model work? The only thing the server needs to do is receive updates from a client and foreward those updates to every other client connected to the server. The server itself doesn’t do any actual message processing.
Is there a more efficient / better way to set up a simple “data forewarding” server? I’m not -too- concerned about lag issues at the moment, just that it will work and every player will be relatively in-sync. And, on that note… how can I ensure that each of the clients IS in sync with all of the others?
Any input/ideas would be greatly appreciated