コード例 #1
0
ファイル: TCPState.cs プロジェクト: top501/DVTK-1
        public void UsedData(uint Length, int direction)
        {
            Position[direction] -= Length;
            Array.Copy(data[direction], Length, data[direction], 0, (int)Position[direction]);
            // now tidy up "times" data

            lock (Times[direction])
            {
                int       count = 0;
                SeqNumber s     = Sequence[direction] - (int)Position[direction];
                s -= 1500;                  // safety to prevent unwanted removals (should really be done with a max value!)
                for (int i = 0; i < Times[direction].Count; i++)
                {
                    PacketTime pt = Times[direction][i] as PacketTime;
                    if (pt.sequence < s)
                    {
                        count = i + 1;
                    }
                }
                if (count > 0)
                {
                    Times[direction].RemoveRange(0, count);
                }
            }
        }
コード例 #2
0
ファイル: TCPState.cs プロジェクト: top501/DVTK-1
        public DateTime GetTime(int direction, long Pos)
        {
            PacketTime best = null;            //Times[direction][0] as PacketTime;
            // initial sequence number = current max sequence (sequence) - position
            // wanted position = that + Pos
            SeqNumber s = Sequence[direction] + (int)(Pos - Position[direction]);

            foreach (PacketTime pt in Times[direction])
            {
                if (pt != null)
                {
                    if ((pt.sequence <= s) && ((best == null) || (pt.sequence > best.sequence)))
                    {
                        best = pt;
                    }
                }
            }

            if (best != null)
            {
                return(best.time);
            }
            else
            {
                return(new DateTime(1970, 1, 1, 0, 0, 0));
            }
        }
コード例 #3
0
ファイル: PacketTCP.cs プロジェクト: ewcasas/DVTK
 public PacketTime(DateTime t, SeqNumber s)
 {
     time = t;
     sequence = s;
 }
コード例 #4
0
ファイル: PacketTCP.cs プロジェクト: top501/DVTK-1
 public PacketTime(DateTime t, SeqNumber s)
 {
     time     = t;
     sequence = s;
 }