private void __SendThreadFunc()
{
while (false == m_IPAddrMsg.m_IsNeedClose && true == m_IPAddrMsg.m_IsConnect && null != m_Socket)
{
SocketNetPacket sendpack = null;
//取出消息缓存中最前一条数据
lock (m_SendObject)
{
if (m_SendPackList.Count != 0)
{
sendpack = m_SendPackList.First.Value;
m_SendPackList.RemoveFirst();
}
}
//发包给服务器
if (null != sendpack)
{
try
{
int nBufferSize = 0;
Byte[] sendBuffer = sendpack.GetBuffer(out nBufferSize);
int sendsize = m_Socket.Send(sendBuffer, 0, nBufferSize, SocketFlags.None);
if (sendsize != nBufferSize)
{
Debug.LogError("NetTCPSocketConnect::__SendThreadFunc send buffer size error:");
m_IPAddrMsg.m_IsNeedClose = true;
break;
}
m_unSendTotalBytes += (uint)sendsize;
}
catch (System.Exception exception)
{
Debug.LogError("NetTCPSocketConnect::__SendThreadFunc send buffer size error:" + exception.ToString());
m_IPAddrMsg.m_IsNeedClose = true;
break;
}
}
else
{
m_ManualSendEvent.WaitOne();
}
}
if (null == m_Socket)
{
Debug.Log("NetTCPSocketConnect::__SendThreadFunc m_Socket is null");
}
Debug.Log("NetTCPSocketConnect::__SendThreadFunc m_IPAddrMsg.m_IsNeedClose = " + m_IPAddrMsg.m_IsNeedClose);
Debug.Log("NetTCPSocketConnect::__SendThreadFunc m_IPAddrMsg.m_IsConnect = " + m_IPAddrMsg.m_IsConnect);
Debug.Log("NetTCPSocketConnect::__SendThreadFunc send message thread is exit...");
}