Skip to content

Commit

Permalink
Protect against concurrent tries to join a lobby
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreSi committed Jan 29, 2025
1 parent cae036b commit ab85ba7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Extensions/Multiplayer/multiplayertools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1616,9 +1616,8 @@ namespace gdjs {
runtimeScene: gdjs.RuntimeScene,
displayLoader: boolean
) => {
if (displayLoader) {
gdjs.multiplayerComponents.displayLoader(runtimeScene, true);
}
if (_isJoiningOrStartingAGame) return;

const _gameId = gdjs.projectData.properties.projectUuid;
if (!_gameId) {
handleLobbiesError(
Expand All @@ -1627,12 +1626,14 @@ namespace gdjs {
);
return;
}

_isJoiningOrStartingAGame = true;
if (displayLoader) {
gdjs.multiplayerComponents.displayLoader(runtimeScene, true);
}

const quickJoinLobbyRelativeUrl = `/play/game/${_gameId}/public-lobby/action/quick-join`;

// TODO: Protect against the action sent once per frame.

try {
const quickJoinLobbyResponse: QuickJoinLobbyResponse = await gdjs.evtTools.network.retryIfFailed(
{ times: 2 },
Expand Down

0 comments on commit ab85ba7

Please sign in to comment.