Hello~
I am trying to wrap my head around how I should structure Nakama’s matches for my requirements.
So, let’s take this beautiful illustration of the communication (authentication) flow for the game :
Client A: The client sends some credentials to Nakama for authentication
Server A: Nakama answers with the session and a list of matches (servers) the user can connect to
Client B: The client chooses to connect to match Y that essentially is the same as every other match but for english speakers
Now, let’s say that, although every match is pretty much the same, I’d like to run special logic based on the match the player is connected to. For example, run some special event during September 7th only in the Brazilian match (Independence Day).
After reading through the documentation I can’t see how to make the server have different MatchHandlers because the module needs it’s functions to be at the top level and it seems they need to have specific names (matchInit, matchLoop etc.) so I can’t isolate them using classes and I can’t name the functions by server (brazilMatchInit, brazilMatchJoinAttempt etc.).
The only way I could think of doing this would be to make all the logic for each match/server inside a single function (matchLoop, for example) and inside the function itself I’d identify which match the user is connected to and then, if needed, I’d handle custom logic for that match. But doing it this way would make the server code impossible to maintain depending on how many matches and/or custom logic per match I had.
So, any tips on how to structure a server like this would be appreciated.