Exemplo n.º 1
0
        public void HandlePacket(PacketIn packet)
        {
            PacketHandle handle = Handles.Find(s => s.packetId == packet.PacketId);

            if (handle != null)
            {
                System.Object[] obj = new System.Object[1];
                obj[0] = packet;

                try
                {
                    if (packet.PacketId.Service == ServiceType.Logon)
                    {
                        Log.WriteLine(LogType.Network, "Handling packet: {0}", handle.packetId);
                        handle.MethodInfo.Invoke(tClient, obj);
                    }
                    else if (packet.PacketId.Service == ServiceType.World)
                    {
                        Log.WriteLine(LogType.Network, "Handling packet: {0}", handle.packetId);
                        handle.MethodInfo.Invoke(wClient, obj);
                    }
                    //Log.WriteLine(LogType.Packet, packet.ToHex());
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                //Log.WriteLine(LogType.Normal, "Unhandled packet: {0}", packet.PacketId.ToString());
            }
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            PacketHandlerAtribute atribute;
            Assembly asm = Assembly.GetCallingAssembly();
            int      x   = 0;

            foreach (Type asmType in asm.GetTypes())
            {
                foreach (MethodInfo method in asmType.GetMethods())
                {
                    foreach (Attribute attr in method.GetCustomAttributes(true))
                    {
                        atribute = attr as PacketHandlerAtribute;
                        if (null != atribute)
                        {
                            PacketHandle handle = new PacketHandle(method, atribute.PacketID);
                            Handles.Add(handle);
                            x++;
                        }
                    }
                }
            }
            Log.WriteLine(LogType.Success, "Loaded {0} Packet handlers.", x);
        }
Exemplo n.º 3
0
        public void Initialize()
        {
            PacketHandlerAtribute atribute;
            Assembly asm = Assembly.GetCallingAssembly();
            int x = 0;
            foreach (Type asmType in asm.GetTypes())
            {

                foreach (MethodInfo method in asmType.GetMethods())
                {
                    foreach (Attribute attr in method.GetCustomAttributes(true))
                    {
                        atribute = attr as PacketHandlerAtribute;
                        if (null != atribute)
                        {
                            PacketHandle handle = new PacketHandle(method, atribute.PacketID);
                            Handles.Add(handle);
                            x++;
                        }
                    }
                }
            }
            Log.WriteLine(LogType.Success, "Loaded {0} Packet handlers.", x);
        }