void IOutStatsCollector.PacketSent(long now, int octetCount) { var p = new OutPacketStatus { SavedAt = now, OctetSize = octetCount }; Add(p); }
void IOutStatsCollector.SequencePacketSent(uint sequenceId, long now, int octetCount) { var p = new OutPacketStatus { SequenceId = sequenceId, HasSequenceId = true, SavedAt = now, OctetSize = octetCount }; Add(p); }
void Add(OutPacketStatus p) { const int MaxCount = 127; if (queue.Count > MaxCount) { queue.TryDequeue(out OutPacketStatus result); } p.StatsPacketId = statsPacketId++; queue.Enqueue(p); }
public OutStats GetInfo(int maxCount) { var wholeArray = queue.ToArray(); var clamp = maxCount; if (clamp > wholeArray.Length) { clamp = wholeArray.Length; } var index = wholeArray.Length - clamp; var copiedPackets = new OutPacketStatus[clamp]; Array.Copy(wholeArray, index, copiedPackets, 0, clamp); return(new OutStats { packetInfo = copiedPackets }); }