1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-15 14:46:29 +09:00

NetConnection.UnsentBytesCount added

This commit is contained in:
lidgren
2010-09-07 06:53:23 +00:00
parent fa3bd2646f
commit c185b3b16f
5 changed files with 55 additions and 3 deletions

View File

@@ -82,6 +82,33 @@ namespace Lidgren.Network
/// </summary>
public NetPeer Owner { get { return m_owner; } }
/// <summary>
/// Gets the number of bytes queued for sending to this connection
/// </summary>
public int UnsentBytesCount
{
get
{
int mtu = m_owner.Configuration.MaximumTransmissionUnit - NetConstants.FragmentHeaderSize;
int retval = 0;
NetSending[] arr = m_unsentMessages.ToArray();
foreach (NetSending send in arr)
{
if (send.FragmentGroupId == 0)
{
retval += send.Message.LengthBytes;
}
else
{
int thisFragmentLength = (send.FragmentNumber == send.FragmentTotalCount - 1 ? (send.Message.LengthBytes - (mtu * (send.FragmentTotalCount - 1))) : mtu);
retval += thisFragmentLength;
}
}
return retval;
}
}
internal NetConnection(NetPeer owner, IPEndPoint remoteEndpoint)
{
m_owner = owner;