示例#1
0
        public FFWorker BindHandler <OBJ_TYPE, T>(object cmdregO, PbHandler <OBJ_TYPE, T> method) where T : pb::IMessage, new() where OBJ_TYPE : new()
        {
            int cmdreg = (int)cmdregO;

            m_dictCmd2Func[cmdreg] = new CmdRegInfo()
            {
                cmdName    = cmdregO.ToString(),
                cmdHandler = (Int64 sid, int cmdSrc, byte[] data) =>
                {
                    int cmd = cmdSrc;
                    if ((cmd & 0x4000) != 0)
                    {
                        cmd &= ~(0x4000);
                    }
                    T reqMsg = Util.Byte2Pb <T>(data);
                    if (funcSessionID2Object != null)
                    {
                        object o = funcSessionID2Object(sid, cmdSrc, data);
                        if (o != null && o is OBJ_TYPE)
                        {
                            OBJ_TYPE obj = (OBJ_TYPE)o;
                            method(obj, reqMsg);
                        }
                    }
                }
            };
            return(this);
        }
示例#2
0
 public FFWorker BindHandler <T>(Pbmsg.ClientCmdDef cmd, PbHandler <T> method) where T : pb::IMessage, new()
 {
     m_dictCmd2Func[(int)cmd] = (Player player, byte[] data) =>
     {
         T reqMsg = Util.Byte2Pb <T>(data);
         method(player, reqMsg);
     };
     return(this);
 }
示例#3
0
        public FFWorker BindHandler <T>(Pbmsg.ClientCmdDef cmd, PbHandler <T> method) where T : pb::IMessage, new()
        {
            CmdHandler ch = (Player player, string data) =>
            {
                T reqMsg = Util.String2Pb <T>(data);
                method(player, reqMsg);
            };

            m_dictCmd2Func[(int)cmd] = ch;
            return(this);
        }