I'm working on a game where players connect to a game server and to a lobby to play a card game against others.
I have a pretty good idea how to code it and such, I'm just not sure regarding a few details.
The game will have multiple lobbies, so although all lobbies run from the same exe and server, the player is bound to a specific lobby.
When the player connects to a lobby, I need to:
-Tell all the players in the lobby about it
-Send that player their list of online friends
-Send that player the list of all players online (in that lobby)
-Send that player the list of all current games and who's playing in each game (This info is all displayed in a ListBox).
Once that player is connected, I need to ensure that while they were receiving that information, if anyone else joined, or any games ended / started etc, that they dont miss any of those messages.
In a single-threaded world, I'd find this pretty simple, but I fear this would mean horrible lag or something every time someone joins. (I could be wrong though).
I'm wondering in general what would be an ideal way to tackle this problem such that it minimizes slow downs for other players. What I mean is, the whole server should not halt for 3 seconds while a user joins.
I guess with a message system it is not too bad since the server can get work done while it waits for the reply. But how robust is such a message system? Login / Authentication be on its own thread, and then it sends a message to the lobby thread which would handle any lobby related transactions. Should each game be in its own thread or should I loop through each active game and process them iteratively?
In addition, each game has a private chat between the 4 players. Each lobby has a chat that only players in the lobby and not in a game can see.
I was also wondering if I should incrementally update the lobby for players in a game or send them a full update when they finish a game.
If anyone could lead me in the right direction for any or all of these questions I would really appreciate it.
I'm coding this in C++ with a network library called ENet, but I'm not looking for any code, but maybe psudocode.