示例#1
0
        public virtual void Init()
        {
            _dictItem.Clear();
            List <Type> ls = ClassUtil.GetClasses(_strSearchNameSpace);

            if (ls.Count == 0)
            {
                Debug.LogWarning("<color=orange>[Warning]</color>---" + _strSearchNameSpace + "中找不到任何消息类型!");
                return;
            }
            for (int i = 0; i < ls.Count; ++i)
            {
                ProtoNetMsgAttribute attr = ClassUtil.GetAttribute(ls[i], typeof(ProtoNetMsgAttribute)) as ProtoNetMsgAttribute;
                if (attr == null)
                {
                    continue;
                }

                CMD_Command cmd = new CMD_Command(attr.mainID, attr.subID);
                if (!_dictItem.ContainsKey(cmd))
                {
                    _dictItem.Add(cmd, new MsgItem());
                }

                if (attr.msgTyp == ProtoNetMsgAttribute.MsgType.Req)
                {
                    _dictItem[cmd].msgReq = ls[i];
                }
                else
                {
                    _dictItem[cmd].msgRespNtf = ls[i];
                }
            }
        }
 public CMD_Base_Req CreateReqMsg(CMD_Command cmd)
 {
     if (_dictCreateReq.ContainsKey(cmd))
     {
         return(_dictCreateReq[cmd]());
     }
     return(null);
 }
 public CMD_Base_RespNtf CreateRespNtfMsg(CMD_Command cmd)
 {
     if (_dictCreateRespNtf.ContainsKey(cmd))
     {
         return(_dictCreateRespNtf[cmd]());
     }
     return(null);
 }
示例#4
0
        public virtual CMD_Base_Req CreateReqMsg(CMD_Command cmd)
        {
            if (!_dictItem.ContainsKey(cmd))
            {
                return(null);
            }

            try
            {
                CMD_Base_Req msg = Activator.CreateInstance(_dictItem[cmd].msgReq) as CMD_Base_Req;
                return(msg);
            }
            catch (System.Exception ex)
            {
                Debug.LogError("<color=red>[Error]</color>---" + "CreateReqMsg 创建失败!!:" + ex.Message);
                return(null);
            }
        }
 public QueueItem(short wMainCmdId, short wSubCmdId, CMD_Base_RespNtf msgBase, string msg = "")
 {
     _cmd     = new CMD_Command(wMainCmdId, wSubCmdId);
     _msgBase = msgBase;
     _strMsg  = msg;
 }