public SendToTransport ( |
||
conn | ||
channelId | int | |
return | bool |
public bool SendToTransport(NetworkConnection conn, int channelId)
{
byte num;
bool flag = true;
if (!conn.TransportSend(this.m_Buffer, (ushort) this.m_Position, channelId, out num) && (!this.m_IsReliable || (num != 4)))
{
if (LogFilter.logError)
{
Debug.LogError(string.Concat(new object[] { "Failed to send internal buffer channel:", channelId, " bytesToSend:", this.m_Position }));
}
flag = false;
}
if (num != 0)
{
if (this.m_IsReliable && (num == 4))
{
NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Outgoing, 30, "msg", 1);
return false;
}
if (LogFilter.logError)
{
Debug.LogError(string.Concat(new object[] { "Send Error: ", (NetworkError) num, " channel:", channelId, " bytesToSend:", this.m_Position }));
}
flag = false;
}
this.m_Position = 0;
return flag;
}
}
public bool SendInternalBuffer() { #if UNITY_EDITOR UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing, MsgType.LLAPIMsg, "msg", 1); #endif if (m_IsReliable && m_PendingPackets.Count > 0) { // send until transport can take no more while (m_PendingPackets.Count > 0) { var packet = m_PendingPackets.Dequeue(); if (!packet.SendToTransport(m_Connection, m_ChannelId)) { m_PendingPackets.Enqueue(packet); break; } pendingPacketCount -= 1; FreePacket(packet); if (m_IsBroken && m_PendingPackets.Count < (m_MaxPendingPacketCount / 2)) { if (LogFilter.logWarn) { Debug.LogWarning("ChannelBuffer recovered from overflow but data was lost."); } m_IsBroken = false; } } return true; } return m_CurrentPacket.SendToTransport(m_Connection, m_ChannelId); }