Example #1
0
        private static void _DetectMethod_Handler(Type cls, MethodInfo mi, PacketHandlePhase phase, ServiceRegHolderClass holderCls)
        {
            Type attrTy = (phase == PacketHandlePhase.Handle ? typeof(HandlerAttribute) : (
                               phase == PacketHandlePhase.PreHandle ? typeof(PreHandlerAttribute) : typeof(UnifyPreHandlerAttribute)));
            Attribute attr = mi.GetCustomAttribute(attrTy, false);

            if (attr == null)
            {
                return;
            }

            if (phase == PacketHandlePhase.Handle)
            {
                ServiceRegHolderMethod holderMethod = _GetHolderMethod(holderCls, mi);
                holderMethod.asHandler     = true;
                holderMethod.handlerOpcode = (attr as HandlerAttribute).opcode;
            }
            else if (phase == PacketHandlePhase.PreHandle)
            {
                ServiceRegHolderMethod holderMethod = _GetHolderMethod(holderCls, mi);
                holderMethod.asPreHandler     = true;
                holderMethod.preHandlerOpcode = (attr as PreHandlerAttribute).opcode;
            }
            else
            {
                ServiceRegHolderMethod holderMethod = _GetHolderMethod(holderCls, mi);
                holderMethod.asUnifyPreHandler = true;
            }
        }
Example #2
0
        private static ServiceRegHolderMethod _GetHolderMethod(ServiceRegHolderClass holderCls, MethodInfo mi)
        {
            ServiceRegHolderMethod holderMethod;

            if (holderCls.methods.TryGetValue(mi, out holderMethod))
            {
                return(holderMethod);
            }

            holderMethod = new ServiceRegHolderMethod(mi);
            holderCls.methods.Add(mi, holderMethod);

            return(holderMethod);
        }
Example #3
0
        private static void _DetectMethod_FrameExcHandler(Type cls, MethodInfo mi, ServiceRegHolderClass holderCls)
        {
            FrameExcHandlerAttribute attr = mi.GetCustomAttribute(
                typeof(FrameExcHandlerAttribute), false) as FrameExcHandlerAttribute;

            if (attr == null)
            {
                return;
            }

            ServiceRegHolderMethod holderMethod = _GetHolderMethod(holderCls, mi);

            holderMethod.asFrameExcHandler = true;
        }
Example #4
0
        private static void _DetectMethod_PacketExcHandler(Type cls, MethodInfo mi, ServiceRegHolderClass holderCls)
        {
            object[] attrs = mi.GetCustomAttributes(typeof(PacketExcHandlerAttribute), false);
            for (int i = 0; i < attrs.Length; i++)
            {
                PacketExcHandlerAttribute attr = attrs[i] as PacketExcHandlerAttribute;

                ServiceRegHolderMethod holderMethod = _GetHolderMethod(holderCls, mi);
                if (attr.phase == PacketHandlePhase.Handle)
                {
                    if (attr.asDefault)
                    {
                        holderMethod.asDftExcHandler = true;
                    }
                    else
                    {
                        holderMethod.asExcHandler = true;
                        _MergeOpcodes(ref holderMethod.excHandlerOpcodes, attr.opcodes);
                    }
                }
                else if (attr.phase == PacketHandlePhase.PreHandle)
                {
                    if (attr.asDefault)
                    {
                        holderMethod.asDftExcPreHandler = true;
                    }
                    else
                    {
                        holderMethod.asExcPreHandler = true;
                        _MergeOpcodes(ref holderMethod.excPreHandlerOpcodes, attr.opcodes);
                    }
                }
                else
                {
                    holderMethod.asExcUnifyPreHandler = true;
                }
            }
        }