Ejemplo n.º 1
0
        void IOutStatsCollector.PacketSent(long now, int octetCount)
        {
            var p = new OutPacketStatus {
                SavedAt = now, OctetSize = octetCount
            };

            Add(p);
        }
Ejemplo n.º 2
0
        void IOutStatsCollector.SequencePacketSent(uint sequenceId, long now, int octetCount)
        {
            var p = new OutPacketStatus {
                SequenceId = sequenceId, HasSequenceId = true, SavedAt = now, OctetSize = octetCount
            };

            Add(p);
        }
Ejemplo n.º 3
0
        void Add(OutPacketStatus p)
        {
            const int MaxCount = 127;

            if (queue.Count > MaxCount)
            {
                queue.TryDequeue(out OutPacketStatus result);
            }
            p.StatsPacketId = statsPacketId++;

            queue.Enqueue(p);
        }
Ejemplo n.º 4
0
        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
            });
        }