I'm trying to do some socket programming based on the following situation:
I have a directory service named Casino that will hold all the information regarding the gamers that will try to connect to it in order to play a game(for example (Blackjack).Once they make the login they are connected to the Casino and can choose from different available games(example Blackjack 1,Blackjack 2,etc...).
My problem is how do I know who will be the host in a given moment?Like,for example when a gamer tries to connect to the Casino directory service, will be the host and the gamer will be the client?Also, it is possible to have many clients logging in the casino...And when the gamer is connected to the casino he can choose between different games and now the games will be the host?And will be different games listening on different ports?How will the casino directory service handle the client connections?
If someone could do a sketch of how it will turn out the whole interaction(as well as the different messages processed between the game/gamer/casino) I'll be very thankful!
I would design for a central server which takes care of spawning a second level server dedicated to accept connections based on the incoming requests ONLY for a particular game.
For example:
at the start of everything where there is no game and no client request,
only one central server would be running
when there is a login to play a game ' blackjack ', the central server would spawn an instance such that the new instance would become the host and takes care of accepting connections from the client which are interested in playing only ' blackjack ' game.
If there is another request to play another game where the game has not yet been started, another instance of the central server would be made, which becomes the host and starts accepting incoming connection requests from the clients to play the game.
If a particular client wants to change the game that he wants to play, request to be made to the host / local second level server, so that the local second level server would contact the main central server whether that game has been already started or yet to be started.
If that is already started, the connection should be re-established to the host which has started the game that the client currently wants to play
If that has not been started already, an info message that no such game as been started and whether the client wants to start the game - thereby the client connection would terminate and again a new instance would start to host the game that it had wished for.