Exemple #1
0
        public void UdpChannel_Send()
        {
            UdpTestMsg msg;

            StartRouters(false);

            try
            {
                g1r1.Transmit(new ChannelEP(Transport.Udp, g1r2.UdpEP), new UdpTestMsg("Hello World!"));
                g1r2.WaitReceived(1);
                msg = (UdpTestMsg)g1r2.DequeueReceived();
                Assert.AreEqual(msg.Value, "Hello World!");
                Assert.AreEqual(Transport.Udp, msg._FromEP.ChannelEP.Transport);
                Assert.AreEqual(NetHelper.GetActiveAdapter(), msg._FromEP.ChannelEP.NetEP.Address);
                Assert.AreEqual(g1r1.UdpEP.Port, msg._FromEP.ChannelEP.NetEP.Port);

                Thread.Sleep(50);
                Assert.AreEqual(0, g1r1.ReceiveCount);
                Assert.AreEqual(0, g1r3.ReceiveCount);
                Assert.AreEqual(0, g2r1.ReceiveCount);
                Assert.AreEqual(0, g2r2.ReceiveCount);
            }
            finally
            {
                StopRouters();
            }
        }
Exemple #2
0
        public void TcpChannel_SendSelf()
        {
            TcpTestMsg msg;

            StartRouters(false);
            g1r1.IdleCheck = false;
            g1r2.IdleCheck = false;

            try
            {
                g1r1.Transmit(new ChannelEP(Transport.Tcp, g1r1.TcpEP), new TcpTestMsg("Hello World!"));
                g1r1.WaitReceived(1);
                msg = (TcpTestMsg)g1r1.DequeueReceived();
                Assert.AreEqual("Hello World!", msg.Value);
                Assert.AreEqual(g1r1.TcpEP.Port, msg._FromEP.ChannelEP.NetEP.Port);
                Assert.AreEqual(NetHelper.GetActiveAdapter(), msg._FromEP.ChannelEP.NetEP.Address);

                g1r1.Transmit(new ChannelEP(Transport.Tcp, g1r1.TcpEP), new TcpTestMsg("#2"));
                g1r1.WaitReceived(1);
                msg = (TcpTestMsg)g1r1.DequeueReceived();
                Assert.AreEqual("#2", msg.Value);
            }
            finally
            {
                StopRouters();
            }
        }
Exemple #3
0
        public void UdpChannel_Multicast()
        {
            UdpTestMsg msg;

            StartRouters(false);

            try
            {
                g1r1.Multicast(new UdpTestMsg("Hello World!"));
                g1r1.WaitReceived(1);
                g1r2.WaitReceived(1);
                g1r3.WaitReceived(1);
                msg = (UdpTestMsg)g1r1.DequeueReceived();
                Assert.AreEqual(msg.Value, "Hello World!");
                Assert.AreEqual(Transport.Multicast, msg._FromEP.ChannelEP.Transport);
                Assert.AreEqual(g1r1.CloudEP.Port, msg._FromEP.ChannelEP.NetEP.Port);

                msg = (UdpTestMsg)g1r2.DequeueReceived();
                Assert.AreEqual(msg.Value, "Hello World!");
                Assert.AreEqual(Transport.Multicast, msg._FromEP.ChannelEP.Transport);
                Assert.AreEqual(g1r1.CloudEP.Port, msg._FromEP.ChannelEP.NetEP.Port);

                msg = (UdpTestMsg)g1r3.DequeueReceived();
                Assert.AreEqual(msg.Value, "Hello World!");
                Assert.AreEqual(Transport.Multicast, msg._FromEP.ChannelEP.Transport);
                Assert.AreEqual(g1r1.CloudEP.Port, msg._FromEP.ChannelEP.NetEP.Port);

                Thread.Sleep(50);
                Assert.AreEqual(0, g2r1.ReceiveCount);
                Assert.AreEqual(0, g2r2.ReceiveCount);

                g2r1.Multicast(new UdpTestMsg("Hello World #2!"));
                g2r1.WaitReceived(1);
                g2r2.WaitReceived(1);
                msg = (UdpTestMsg)g2r1.DequeueReceived();
                Assert.AreEqual(msg.Value, "Hello World #2!");
                Assert.AreEqual(Transport.Multicast, msg._FromEP.ChannelEP.Transport);
                Assert.AreEqual(g2r1.CloudEP.Port, msg._FromEP.ChannelEP.NetEP.Port);

                msg = (UdpTestMsg)g2r2.DequeueReceived();
                Assert.AreEqual(msg.Value, "Hello World #2!");
                Assert.AreEqual(Transport.Multicast, msg._FromEP.ChannelEP.Transport);
                Assert.AreEqual(g2r1.CloudEP.Port, msg._FromEP.ChannelEP.NetEP.Port);

                Thread.Sleep(50);
                Assert.AreEqual(0, g1r1.ReceiveCount);
                Assert.AreEqual(0, g1r2.ReceiveCount);
                Assert.AreEqual(0, g1r3.ReceiveCount);
            }
            finally
            {
                StopRouters();
            }
        }