using System; using System.Net; using System.Threading; using System.Reflection; using System.Net.Sockets; using FilterAPI.Networking; using FilterManager.LocalHandlers; namespace FilterManager.LocalNetworking { internal class LocalClient : SingleClient, IDisposable { public LocalClient() : base(IPAddress.Parse(Program.Conf.GetConfigValue("MainBindIP")), Convert.ToInt32(Program.Conf.GetConfigValue("MainBindPort"))) { } public override void Connected() { using (var P = new Packet(LocalNETCMD.NAME)) { P.PacketWriter.Write("FilterManager"); SendPacket(P); } } public void SendPacket(Packet ServerPacket) { Byte[] PacketBuffer; ServerPacket.ToArray(out PacketBuffer); Send(PacketBuffer); } public override void Received(Byte[] Buffer) { using (var ClientPacket = new Packet(Buffer)) { if (!ClientPacket.SetOPCode()) { Dispose(); } //else if (ClientPacket.OPCode == LocalNETCMD.XFER_KEY) //{ // try // { // MethodInfo PacketMethod = Program.LocalHandlers.GetHandler(LocalNETCMD.XFER_KEY); // Action PacketAction = new Action(delegate () // { // Local3Handle.HandleTransferKey(this, ClientPacket); // }); // PacketAction(); // } // catch (Exception ex) { Program.SendConsoleText(ConsoleColor.Red, ex.Message); } //} else if (Program.LocalHandlers.HasHandler((LocalNETCMD)ClientPacket.OPCode)) { try { MethodInfo PacketMethod = Program.LocalHandlers.GetHandler((LocalNETCMD)ClientPacket.OPCode); Action PacketAction = Program.LocalHandlers.GetAction(PacketMethod, this, ClientPacket); PacketAction(); } catch { } } } } public override void Disconnected() { Program.LocalClient = new LocalClient(); } } }