Turn-based Client-Server Card Game - Unicast (TCP) or Multicast (UDP)

Posted by LDM91 on Game Development See other posts from Game Development or by LDM91
Published on 2012-03-29T21:43:35Z Indexed on 2012/03/29 23:42 UTC
Read the original article Hit count: 305

I am currently planning to make a card game project where the clients will communicate with the server in a turn-based and synchronous manner using messages sent over sockets. The problem I have is how to handle the following scenario:

(Client takes it turn and sends its action to server)

  1. Client sends a message telling the server its move for the turn (e.g. plays the card 5 from its hand which needs to placed onto the table)

  2. Server receives messages and updates game state (server will hold all game state).

  3. Server iterates through a list of connected clients and sends a message to tell of them change in state

  4. Clients all refresh to display the state

This is all based on using TCP, and looking at it now it seems a bit like the Observer pattern. The reason this seems to be an issue to me is this message doesn't seem to be point-to-point like the others as I want to send it to all the clients, and doesn't seem very efficient sending the same message in that way.

I was thinking about using multicasting with UDP as then I could send the message to all the clients, however wouldn't this mean that the clients would in theory be able to message each other? There is of course the synchronous aspect as well, though this could be put on top of the UDP I guess.

Basically, I would like to know what would be good practice as this project is really all about learning, and even though it won't be big enough to encounter performance issues from this I would like to consider them anyway.

However, please note I am not interested in using message oriented middleware as a solution (I have experience with using MOM and I'm interested in considering other options excluding MOM if TCP sockets is a bad idea!).

© Game Development or respective owner

Related posts about networking

Related posts about client-server