/// <summary> /// 注销mono对一组消息的关注 /// </summary> /// <param name="mono"></param> /// <param name="msgIds"></param> public void UnRegistMsgs(IMessageProcess mono, params ushort[] msgIds) { for (int i = 0; i < msgIds.Length; i++) { UnRegistMsg(mono, msgIds[i]); } }
/// <summary> /// 注销消息 /// </summary> public void UnRegistMsgs(IMessageProcess mono, List <ushort> msgIds) { for (int i = 0; i < msgIds.Count; i++) { switch (MsgBase.GetMsgType(msgIds[i])) { case MsgType.UI: uiMgr.UnRegistMsg(mono, msgIds[i]); break; case MsgType.Net: netMgr.UnRegistMsg(mono, msgIds[i]); break; case MsgType.Entity: entityMgr.UnRegistMsg(mono, msgIds[i]); break; case MsgType.Audio: audioMgr.UnRegistMsg(mono, msgIds[i]); break; case MsgType.Asset: assetMgr.UnRegistMsg(mono, msgIds[i]); break; } } }
/// <summary> /// 注销mono对msgId的关注 /// </summary> /// <param name="mono"></param> /// <param name="msgId"></param> public void UnRegistMsg(IMessageProcess mono, ushort msgId, byte priority) { priority = GetLegalPriority(priority); if (eventTree[priority] != null && eventTree[priority].ContainsKey(msgId) && eventTree[priority][msgId].Contains(mono)) { eventTree[priority][msgId].Remove(mono); } }
/// <summary> /// 注册一个消息,带优先级 /// </summary> /// <param name="mono">关注msgId的Mono</param> /// <param name="msgId">消息id</param> public void RegistMsg(IMessageProcess mono, ushort msgId, byte priority) { priority = GetLegalPriority(priority); if (eventTree[priority] == null) { eventTree[priority] = new Dictionary <ushort, HashSet <IMessageProcess> >(); } if (!eventTree[priority].ContainsKey(msgId)) { HashSet <IMessageProcess> set = new HashSet <IMessageProcess>(); eventTree[priority].Add(msgId, set); } if (!eventTree[priority][msgId].Contains(mono)) { eventTree[priority][msgId].Add(mono); Debug.Log("mono registered, msgId == " + msgId); } }
public override void Accept(IMessageProcess processor) { processor.Process(this); }
/// <summary> /// Xử lý message bởi processor /// </summary> /// <param name="processor"></param> /// <returns></returns> public abstract void Accept(IMessageProcess processor);
/// <summary> /// 取消注册消息 /// </summary> /// <param name="messages"></param> /// <param name="messageProcess"></param> public void UnRegistMessage(ushort[] messages, IMessageProcess messageProcess) { nodeList.RemoveNode(messages, messageProcess); }
/// <summary> /// 注册消息 /// </summary> /// <param name="messages"></param> /// <param name="messageProcess"></param> public void RegistMessage(ushort[] messages, IMessageProcess messageProcess) { nodeList.AddNode(messages, messageProcess); }
/// <summary> /// 注销mono对msgId的关注,不带优先级,按优先级7处理 /// </summary> /// <param name="mono"></param> /// <param name="msgId"></param> public void UnRegistMsg(IMessageProcess mono, ushort msgId) { UnRegistMsg(mono, msgId, 7); }