Hi,
In our game we are running an authoritative match loop, though we handle match creation ourselves using a custom RPC, without using the matchmaker.
Each area of our game can have a single match running, using a unique label. So when a player arrives at that area we do the following:
- We query all active matches using the area label:
const matches = nk.matchList(1, true, query);
if (matches[0]) {
response.matchId = matches[0].matchId;
}
} catch (error) {}
If a match is active, we return that match.
- If not, we go forward and create a new match and return that instead:
if (!response.matchId) {
const params = {
lobbyId: lobbyId,
};
const matchId = nk.matchCreate(moduleName, params);
response.matchId = matchId;
}
That works perfectly fine unless we initiate two sessions at the same instant, that would be two players pressing the connect button approximately at the same time.
Then the above code may create in some cases two different match instances. We were under the impression that all RPCs are executed in a sequence, isn’t that the case?
Is there a case why the above code will execute in parallel or if that is not the case, then why matchList() running for the 2nd player wouldn’t find the match created just before by the 1st player? Does it take a while for the server to register that match?
Thank you,