示例#1
0
        void ProccessMessage()
        {
            // while (true)
            {
                //yield return new WaitForFixedUpdate();

                //检查是否有连接错误
                CheckConnectError();
                if (m_CurrentSocketClient != null && m_MessageEventHandler != null)
                {
                    recvMessageCount = 0;
                    QueueNode <IPackageData> node = null;
                    do
                    {
                        node = m_oRecieveQueue.Pop();
                        if (null != node)
                        {
                            executePacket(node.item);
                            recvMessageCount++;

                            if (m_oRecieveRecycle.Size() < MAX_CACHE_SIZE)
                            {
                                PackageData packData = (PackageData)node.item;
                                if (null != packData)
                                {
                                    // packData.m_senddata = null;
                                    packData.Release(m_oRecieveMemPool);
                                }

                                m_oRecieveRecycle.Push(node);
                            }
                            else
                            {
                                node.item.Release(m_oRecieveMemPool);
                                node.item = null;
                            }
                        }
                    } while (null != node);
                }
            }
        }
示例#2
0
 //发送一个数据包完毕
 public void OnFinishSendData(QueueNode <IPackageData> node)
 {
     if (m_oSendRecycle.Size() < MAX_CACHE_SIZE)
     {
         PackageData packData = (PackageData)node.item;
         if (null != packData)
         {
             packData.Release(m_oRecieveMemPool);
         }
         m_oSendRecycle.Push(node);
     }
     else
     {
         node.item.Release(m_oRecieveMemPool);
         node.item = null;
     }
 }