예제 #1
0
 public static void EnqueueRecv(IS2C_Msg msg)
 {
     lock (mRecvLocker)
     {
         mReceivedMessageQueue.Enqueue(msg);
     }
 }
예제 #2
0
        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();
            }
        }