/// <summary> /// 删除监听 /// </summary> /// <param name="protoCode"></param> /// <param name="handler"></param> public void RemoveEventListener(ushort protoCode, OnActionHandle handler) { if (dic.ContainsKey(protoCode)) { List <OnActionHandle> HandleList = dic[protoCode]; HandleList.Remove(handler); if (HandleList.Count == 0) { dic.Remove(protoCode); } } }
/// <summary> /// 添加监听 /// </summary> /// <param name="protoCode"></param> /// <param name="handler"></param> public void AddEventListener(ushort protoCode, OnActionHandle handler) { if (dic.ContainsKey(protoCode)) { dic[protoCode].Add(handler); } else { List <OnActionHandle> HandleList = new List <OnActionHandle>(); HandleList.Add(handler); dic[protoCode] = HandleList; } }