TurnBased Server Design

by Patrik Bašo   Last Updated August 23, 2019 12:13 PM

I want to create turn based card game. Im currently writing server part in Java and I designed one little mechanism how it could work. On one server I want to be able to have lots of desks. So the basic principse is to have one thread which would be accpeting and checking new connection. This class upon connecting new Player would create new thread for communication with every player. The player could send request. Every PlayerConnection thread would be creating new entry in List named Requests for every request sended by player.. From this List new class called ProccesingUnit would be processing every request one by one, and responses would be add to another List called Responses depending from which connection the request was added. Every PlayerConnection would be having its own Responses list, which would be sended trought TCP to player.

So the general scheme would be something like this

ServerAccepter ->creating PlayerConnection<---Responses | A | | V Processing add entry to Requests -> Unit

My question if there is any better way to handle such a situation?

Another question is what to do about rooms.. Should I make a processing unit for every room or should I handle it globally?



Related Questions



Dynamic Game Server Architecture

Updated June 24, 2019 01:13 AM

Synchronize points from UI and server

Updated June 18, 2019 12:13 PM


How to implement the server-side game loop?

Updated May 19, 2015 04:05 AM