public static async void Authenticate(int fromClient, Packet packet) { AuthCore core = (AuthCore)Server.the_core; int id = packet.ReadInt(); string user = packet.ReadString(); string password = packet.ReadString(); if (!Security.ReceivedIdMatchesClientId(id, fromClient)) { AuthHelpers.SendAuthFailed(fromClient); return; } int aid = await AuthHelpers.GetAidFromLoginPassword(fromClient, user, password); bool hasSession = await AuthHelpers.DoesAidHaveSession(aid); if (!hasSession) { AuthHelpers.SetSessionIDtoClient(fromClient, aid); core.Clients[fromClient].setAID(aid); AuthHelpers.CreateSessionInDatabase(fromClient, aid); CharacterSelectionEntry[] characters = await AuthHelpers.GetCharactersInAccount(aid); AuthHelpers.SendCharacterSelectionDataToClient(fromClient, characters); } else { core.Clients[fromClient].setAID(aid); AuthHelpers.SendAlreadyConnectedPacket(fromClient); AuthHelpers.SendDisconnectPacketToAlreadyConnectedClient(fromClient); } }