예제 #1
0
 public bool AddParseMsgCb(Type type, ParseMessageCallback parsMsgCb)
 {
     try
     {
         if (m_msgFactory == null)
         {
             return(false);
         }
         CMsgID msgID = m_msgFactory.CreateMsgIDByType(type);
         if (msgID == null)
         {
             return(false);
         }
         if (m_hashtable.ContainsKey(msgID.MsgID))
         {
             return(false);
         }
         m_msgFactory.AddMsgType(type);
         m_hashtable.Add(msgID.MsgID, parsMsgCb);
     }
     catch (System.Exception)
     {
         return(false);
     }
     return(true);
 }
예제 #2
0
 public bool AddParseMsgCb(CMsgID msgID, ParseMessageCallback parsMsgCb)
 {
     try
     {
         if (m_hashtable.ContainsKey(msgID.MsgID))
         {
             return(false);
         }
         m_hashtable.Add(msgID.MsgID, parsMsgCb);
     }
     catch (System.Exception)
     {
         return(false);
     }
     return(true);
 }
예제 #3
0
 public bool ParseMessage(CMsg msg)
 {
     try
     {
         if (!m_hashtable.ContainsKey(msg.MsgID.MsgID))
         {
             return(false);
         }
         ParseMessageCallback parsMsgCb = (ParseMessageCallback)m_hashtable[msg.MsgID.MsgID];
         parsMsgCb(msg);
         return(true);
     }
     catch (System.Exception e)
     {
         UnityUtility.CTrace.Singleton.error("处理消息ParseMessage[{0}]失败", e.ToString());
         return(false);
     }
 }