using Filter; using Filter.Handlers.Instances; using Filter.Handlers.Login; using Filter.Networking.Instances; using System; using System.Net; using System.Net.Sockets; using System.Reflection; namespace Filter.Networking.Login { internal class LoginClient : Client, IDisposable { public LoginServer Server; private FiestaCrypto Crypto; public int AccountID; public LoginClient(Socket AcceptedSocket, IPEndPoint AcceptedEndPoint) : base(AcceptedSocket, AcceptedEndPoint) { this.Server = new LoginServer(this); } public override void Connected() { } public override void ConnectFailed(SocketException Exception) { } public override void Disconnected() { this.Server.Disconnect(); } public override void Received(byte[] Buffer) { if (this.IsConnected != 0) { return; } if (this.Crypto != null) { this.Crypto.Crypt(Buffer, 0, (int)Buffer.Length); } Packet packet = new Packet(Buffer); if (!packet.SetHeaderAndType()) { base.Disconnect(); return; } if (!Program.LoginHandlers.HasHandler(packet.Header, packet.Type)) { this.Server.SendPacket(packet); } else { try { MethodInfo handler = Program.LoginHandlers.GetHandler(packet.Header, packet.Type); LoginHandlerLoader loginHandlers = Program.LoginHandlers; object[] objArray = new object[] { this, packet }; loginHandlers.GetAction(handler, objArray)(); } catch (Exception exception1) { Exception exception = exception1; this.SendPacket(packet); Program.WriteError(exception); } } } public void SendCrypto() { if (this.IsConnected != 0) { return; } this.Crypto = new FiestaCrypto(2); Packet packet = new Packet(Login2TypeServer.SetXor); packet.WriteInt16(2); this.SendPacket(packet); } public void SendPacket(Packet ServerPacket) { byte[] numArray; if (this.IsConnected != 0) { return; } ServerPacket.ToArray(out numArray); base.Send(numArray); } } }