Esempio n. 1
0
        public static bool Initialize()
        {
            _handlers = new Dictionary <ushort, MethodInfo>();

            foreach (var info in MapleHandler.FindMethodsByAttribute <PacketHandlerAttribute>())
            {
                PacketHandlerAttribute attribute = info.Left;
                MethodInfo             method    = info.Right;

                if (!_handlers.ContainsKey(attribute.Header))
                {
                    _handlers.Add(attribute.Header, method);
                }
            }

            return(true);
        }
Esempio n. 2
0
        public override void OnPacket(InPacket inPacket)
        {
            MethodInfo method = MapleHandler.GetHandler(inPacket.OperationCode);

            if (method == null)
            {
                base.OnPacket(inPacket);
                return;
            }

            try
            {
                MapleHandler.GetCallback(method, this, inPacket)();
            }
            catch (Exception e)
            {
                Debug.WriteLine("Packet handling exception: {0}", e.ToString(), 0);
            }
        }