forked from PGR/ascnet
1
0
Fork 0

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