예제 #1
0
 /// <summary>
 /// 移除监听  [给监听者使用,如果有监听某条消息必须有移除,否则死人还能收到消息]
 /// </summary>
 /// <param name="protoID"></param>
 /// <param name="handler"></param>
 public void RemoveEventListener(ushort protoID, OnActinHandler handler)
 {
     if (dic.ContainsKey(protoID))
     {
         List <OnActinHandler> lsHandler = dic[protoID];
         lsHandler.Remove(handler);
         if (lsHandler.Count == 0)
         {
             dic.Remove(protoID);
         }
     }
 }
예제 #2
0
 /// <summary>
 /// 添加监听 [给监听者使用,想监听了就添加,不需要监听的就不用管]
 /// </summary>
 /// <param name="protoID"></param>
 /// <param name="handler"></param>
 public void AddEventListener(ushort protoID, OnActinHandler handler)
 {
     if (dic.ContainsKey(protoID))
     {
         dic[protoID].Add(handler);
     }
     else
     {
         List <OnActinHandler> lsHandler = new List <OnActinHandler>();
         lsHandler.Add(handler);
         dic[protoID] = lsHandler;
     }
 }