public void CheckRecvedMessage(ITcpNetLogicModel l) { if (!CanWorking) { throw new Exception("CheckRecvedMessage:this tcp networking cannot working, because mNetworkingModel is null"); } IS2C_Msg msg = TcpIPMessageQueue.PeekRecv(); while (null != msg) { bool handled = true; bool breaked = false; if (msg.MessageID == (int)RecvMsgType.S2C_ChangeScene) { UnLockNetMsgScreenLocked(); } else { if (mWaitUnlockMsgs.Contains(msg.MessageID)) { mWaitUnlockMsgs.Remove(msg.MessageID); } if (mWaitUnlockMsgs.Count == 0) { UnLockNetMsgScreenLocked(); } } if (!l.HandleMessage(msg, ref handled, ref breaked)) { Debug.LogError("处理消息[" + (RecvMsgType)msg.MessageID + "]失败!!!"); TcpIPMessageQueue.DequeueRecv(); } if (handled) { TcpIPMessageQueue.DequeueRecv(); } else { Debug.LogError("标记为未处理的消息[" + (RecvMsgType)msg.MessageID + "]"); if (msg.CanDroped) { TcpIPMessageQueue.DequeueRecv(); } break; } if (breaked) { Debug.LogWarning("跳出本次消息处理[" + (RecvMsgType)msg.MessageID + "]"); break; } msg = TcpIPMessageQueue.PeekRecv(); } }
public void UnRegisterRecvDelegate(ITcpNetLogicModel model) { for (int i = 0; i < model.CanRecvMessages.Length; ++i) { var id = (Int32)model.CanRecvMessages[i]; List <ITcpNetLogicModel> models = null; if (mLogicModelRecvDelegates.ContainsKey(id)) { models = mLogicModelRecvDelegates[id]; models.Remove(model); //Debug.Log(string.Format("移除模块[{0}]接收消息[{1}]", model.ToString(), ((接收消息类型)id).ToString())); } } }
public void RegisterRecvDelegate(ITcpNetLogicModel model) { for (int i = 0; i < model.CanRecvMessages.Length; ++i) { var id = (Int32)model.CanRecvMessages[i]; List <ITcpNetLogicModel> models = null; if (!mLogicModelRecvDelegates.ContainsKey(id)) { models = new List <ITcpNetLogicModel>(); models.Add(model); mLogicModelRecvDelegates.Add(id, models); //Debug.Log(string.Format("创建模块消息接收列表[{0}],注册接收消息[{1}]", model.ToString(), ((接收消息类型)id).ToString())); } else { models = mLogicModelRecvDelegates[id]; if (!models.Contains(model)) { models.Add(model); } //Debug.Log(string.Format("为模块[{0}]注册接收消息[{1}]", model.ToString(), ((接收消息类型)id).ToString())); } } }