Fix a bug where a player rejoining triggered a join message and desyncs

This commit is contained in:
Andrio Celos
2022-10-05 16:43:45 +11:00
parent ada0c9f150
commit 59dc677077
3 changed files with 12 additions and 4 deletions

View File

@@ -162,10 +162,11 @@ internal class Program {
SetErrorResponse(e.Response, error.Code == "GameAlreadyStarted" ? (int) HttpStatusCode.Gone : 422, error);
return;
}
game.SendEvent("join", new { playerIndex, player }, false);
}
// If they're already in the game, resend the original join response instead of an error.
SetResponse(e.Response, (int) HttpStatusCode.OK, "application/json", JsonConvert.SerializeObject(new { playerIndex, clientToken }));
game.SendEvent("join", new { playerIndex, player }, false);
timer.Start();
} catch (ArgumentException) {
e.Response.StatusCode = (int) HttpStatusCode.BadRequest;