public byte[] RemoveMostRecentPartialPacket(ref int lastPacketBytesRead)
{
lock (Locker)
{
if (packets.Count > 0)
{
int lastPacketIndex = packets.Count - 1;
lastPacketBytesRead = packetActualBytes[lastPacketIndex];
byte[] returnArray = packets[lastPacketIndex];
totalBytesCached -= packetActualBytes[lastPacketIndex];
packets.RemoveAt(lastPacketIndex);
packetActualBytes.RemoveAt(lastPacketIndex);
if (NetworkComms.LoggingEnabled) NetworkComms.Logger.Trace(" ... reusing byte[" + returnArray.Length + "] from packetBuilder which contains " + lastPacketBytesRead + " existing bytes.");
return returnArray;
}
else
throw new Exception("Unable to remove most recent packet as packet list is empty.");
}
}