Beispiel #1
0
        public void Send_AllInOrder_CorrectOrder()
        {
            var loopback = new Loopback(LoopbackTypes.AllInOrder);
            var lhs      = new UnreliableOrderedConnection(loopback.RhsUpdSend, 1, new NullTrace());
            var rhs      = new UnreliableOrderedConnection(loopback.LhsUdpSend, 1, new NullTrace());

            loopback.RhsUpdSend.Sink = rhs;
            loopback.LhsUdpSend.Sink = lhs;
            var list = new List <Paket>();

            rhs.NewPaket += (p1, p2) => { list.Add(p2); };
            for (int i = 0; i < 100000; i++)
            {
                var paket = lhs.CreatePaket();
                SimpleTypeWriter.Write(i + "Test" + i, paket);
                SimpleTypeWriter.Write(i, paket);
                lhs.Send(paket);
            }
            Assert.Equal(100000, list.Count);
            for (int i = 0; i < list.Count; i++)
            {
                var paket   = list[i];
                var message = SimpleTypeReader.ReadString(paket);
                var number  = SimpleTypeReader.ReadInt(paket);
                Assert.Equal(i, number);
                Assert.Equal(message, i + "Test" + i);
            }
        }
Beispiel #2
0
 public void Deserialize(Paket paket)
 {
     TestString = SimpleTypeReader.ReadString(paket);
     TestNumber = SimpleTypeReader.ReadInt(paket);
 }
Beispiel #3
0
 public void Deserialize(Paket paket)
 {
     ServerName    = SimpleTypeReader.ReadString(paket);
     ServerVersion = SimpleTypeReader.ReadInt(paket);
     RunningId     = SimpleTypeReader.ReadInt(paket);
 }