public override void Run() { bool finished = false; RUDPConnection s = new RUDPConnection(); RUDPConnection c = new RUDPConnection(); s.Create(true, "127.0.0.1", 80); c.Create(false, "127.0.0.1", 80); c.RequestChannel("TEST"); c.OnChannelAssigned += (RUDPChannel ch) => { ch.Connect(); }; c.OnConnected += (RUDPChannel ch) => { finished = true; }; while (!finished) { Thread.Sleep(10); } s.Disconnect(); c.Disconnect(); Assert.AreEqual(State.CLOSED, s.State); Assert.AreEqual(State.CLOSED, c.State); }
public override void Run() { bool finished = false; RUDPConnection s = new RUDPConnection(); RUDPConnection c = new RUDPConnection(); s.Create(true, "127.0.0.1", 80); c.Create(false, "127.0.0.1", 80); c.RequestChannel("TEST"); byte[] buf = new byte[_packetSize * _multiplier]; Random r = new Random(DateTime.Now.Second); r.NextBytes(buf); int counter = 0; c.OnChannelAssigned += (RUDPChannel ch) => { ch.Connect(); }; c.OnConnected += (RUDPChannel ch) => { counter = 0; finished = false; for (int i = 0; i < _packetMax; i++) { ch.SendData(buf); } }; s.OnPacketReceived += (RUDPChannel ch, RUDPPacket p) => { Assert.IsTrue(p.Data.SequenceEqual(buf)); counter++; if (counter >= _packetMax) { finished = true; } }; while (!finished) { Thread.Sleep(10); } c.Disconnect(); s.Disconnect(); Assert.AreEqual(State.CLOSED, s.State); Assert.AreEqual(State.CLOSED, c.State); }
static void Main(string[] args) { RUDPConnection s = new RUDPConnection(); s.Create(true, "127.0.0.1", 80); Thread.Sleep(1000); RUDPConnection c = new RUDPConnection(); c.Create(false, "127.0.0.1", 80); c.OnChannelAssigned += (RUDPChannel channel) => { channel.Connect(); }; c.RequestChannel(c.RemoteEndpoint, "TEST"); Console.ReadKey(); }
public override void Run() { RUDPConnection s = new RUDPConnection(); RUDPConnection c = new RUDPConnection(); s.Create(true, "127.0.0.1", 80); c.Create(false, "127.0.0.1", 80); c.RequestChannel("TEST"); c.OnChannelAssigned += (RUDPChannel ch) => { ch.Connect(); }; c.OnConnected += (RUDPChannel ch) => { Console.WriteLine("10 seconds for keepalive START..."); Thread.Sleep(5000); if (_testServer) { c.Disconnect(); } else { s.Disconnect(); } Thread.Sleep(5000); Console.WriteLine("10 seconds for keepalive END!"); Thread.Sleep(2500); s.Disconnect(); c.Disconnect(); }; while (c.State < State.CLOSING || s.State < State.CLOSING) { Thread.Sleep(10); } Assert.AreEqual(State.CLOSED, s.State); Assert.AreEqual(State.CLOSED, c.State); }