Beispiel #1
0
        public async Task When_ListeningAndSendingMulticastOnIPV4_Then_MessagesAreSentAndReceived()
        {
            UInt16 universe = 1;

            using (var sender = new MulticastSacnSenderIPV4())
            {
                using (var receiver = new MulticastSacnReceiverIPV4())
                {
                    DataPacket received = null;

                    var hostname    = Dns.GetHostName();
                    var ipAddresses = await Dns.GetHostAddressesAsync(hostname);

                    receiver.OnDataPacketReceived += (sender, packet) =>
                    {
                        received = packet;
                    };
                    receiver.Listen(IPAddress.Any);
                    receiver.JoinMulticastGroup(universe);

                    var packet = new DataPacket();
                    packet.FramingLayer.SourceName = "Source name";
                    packet.FramingLayer.Universe   = universe;
                    packet.DMPLayer.PropertyValues = new byte[] { 1, 2, 3, 4 };

                    await sender.Send(packet);

                    await Task.Delay(250);

                    Assert.NotNull(received);
                }
            }
        }
        public void Given_TheAddressIsIPV4_When_ListenIsCalled_Then_ItListensOnTheAddress()
        {
            var ip         = IPAddress.Any;
            var udpWrapper = Mock.Of <IUdpWrapper>();
            var receiver   = new MulticastSacnReceiverIPV4(udpWrapper, null);

            receiver.Listen(ip);
            Mock.Get(udpWrapper)
            .Verify(x => x.Listen(It.Is <IPEndPoint>(e => e.Address.Equals(ip))));
        }
Beispiel #3
0
 static void Main(string[] args)
 {
     using var receiver             = new MulticastSacnReceiverIPV4();
     receiver.OnDataPacketReceived += (sender, packet) =>
     {
         Console.WriteLine(packet.FramingLayer.Universe + ": ");
         Console.WriteLine(string.Join(", ", packet.DMPLayer.PropertyValues));
     };
     receiver.OnSynchronizationPacketReceived += (sender, packet) =>
     {
         Console.WriteLine("Sync!");
     };
     receiver.OnUniverseDiscoveryPacketReceived += (sender, packet) =>
     {
         Console.WriteLine("Discovery!");
     };
     receiver.Listen(IPAddress.Any);
     receiver.JoinMulticastGroup(1);
     Console.WriteLine("Listening. Press enter to exit");
     Console.ReadLine();
 }
        public void Given_TheAddressIsNotIPV4_When_ListenIsCalled_Then_AnExceptionIsThrown()
        {
            var receiver = new MulticastSacnReceiverIPV4(null, null);

            Assert.Throws <ArgumentException>(() => receiver.Listen(IPAddress.IPv6Any));
        }