public async Task ValidateClient(SessionInfoPacket packet, IRakConnection connection) { if (packet == null) { throw new ArgumentNullException(nameof(packet), ResourceStrings.ClientHandler_ValidateClient_PacketNullException); } await UchuServer.ValidateUserAsync(connection, packet.Username, packet.SessionKey) .ConfigureAwait(false); }
public void ValidateClient(SessionInfoPacket packet, IRakConnection connection) { if (!Server.SessionCache.IsKey(packet.SessionKey)) { Task.Run(connection.CloseAsync); Logger.Warning($"{connection} attempted to connect with an invalid session key"); return; } Server.SessionCache.RegisterKey(connection.EndPoint, packet.SessionKey); }
public async Task ValidateClientHandler(SessionInfoPacket packet, IRakConnection connection) { Logger.Information($"{connection.EndPoint}'s validating client for world!"); if (!Server.SessionCache.IsKey(packet.SessionKey)) { await connection.CloseAsync(); Logger.Warning($"{connection} attempted to connect with an invalid session key"); return; } Server.SessionCache.RegisterKey(connection.EndPoint, packet.SessionKey); var session = Server.SessionCache.GetSession(connection.EndPoint); await using var ctx = new UchuContext(); // Try to find the player, disconnect if the player is invalid var character = await ctx.Characters.FindAsync(session.CharacterId); if (character == null) { Logger.Warning( $"{connection} attempted to connect to world with an invalid character {session.CharacterId}" ); connection.Send(new DisconnectNotifyPacket { DisconnectId = DisconnectId.CharacterNotFound }); return; } // Initialize zone for player var zoneId = (ZoneId)character.LastZone; if (zoneId == ZoneId.VentureExplorerCinematic) { zoneId = ZoneId.VentureExplorer; } var worldServer = (WorldServer)Server; var zone = await worldServer.GetZoneAsync(zoneId); Server.SessionCache.SetZone(connection.EndPoint, zoneId); connection.Send(new WorldInfoPacket { ZoneId = zoneId, Checksum = zone.Checksum, SpawnPosition = zone.ZoneInfo.LuzFile.SpawnPoint }); }
public async Task ValidateClientHandler(SessionInfoPacket packet, IRakConnection connection) { Logger.Information($"{connection.EndPoint}'s validating client for world!"); var verified = await UchuServer.ValidateUserAsync(connection, packet.Username, packet.SessionKey); if (!verified) { return; } var session = UchuServer.SessionCache.GetSession(connection.EndPoint); await using var ctx = new UchuContext(); // Try to find the player, disconnect if the player is invalid var character = await ctx.Characters.FindAsync(session.CharacterId); if (character == null) { Logger.Warning( $"{connection} attempted to connect to world with an invalid character {session.CharacterId}" ); connection.Send(new DisconnectNotifyPacket { DisconnectId = DisconnectId.CharacterNotFound }); return; } // Initialize zone for player var zoneId = (ZoneId)character.LastZone; if (zoneId == 0) { zoneId = 1000; } var worldServer = (WorldUchuServer)UchuServer; var zone = await worldServer.GetZoneAsync(zoneId); UchuServer.SessionCache.SetZone(connection.EndPoint, zoneId); connection.Send(new WorldInfoPacket { ZoneId = zoneId, Checksum = zone.Checksum, SpawnPosition = zone.SpawnPosition }); }
public async Task ValidateClient(SessionInfoPacket packet, IRakConnection connection) { await Server.ValidateUserAsync(connection, packet.Username, packet.SessionKey).ConfigureAwait(false); }