prevent a race condition in duplicated session

This commit is contained in:
rfi 2023-12-13 09:25:26 +07:00
parent d289d50221
commit 7208f97f84
1 changed files with 4 additions and 0 deletions

View File

@ -45,6 +45,7 @@ namespace AscNet.GameServer.Handlers
[RequestPacketHandler("LoginRequest")]
public static void LoginRequestHandler(Session session, Packet.Request packet)
{
start:
LoginRequest request = MessagePackSerializer.Deserialize<LoginRequest>(packet.Content);
Player? player = Player.FromToken(request.Token);
@ -63,6 +64,9 @@ namespace AscNet.GameServer.Handlers
// GateServerForceLogoutByAnotherLogin
previousSession.SendPush(new ForceLogoutNotify() { Code = 1018 });
previousSession.DisconnectProtocol();
// Player data will be outdated without refetching it after disconnecting the previous session.
goto start;
}
session.player = player;