Пример #1
0
        public void Silence()
        {
            using (NetMQContext context = NetMQContext.Create())
            {
                using (NetMQBeacon speaker = new NetMQBeacon(context))
                {
                    speaker.Configure(9999);

                    using (NetMQBeacon listener = new NetMQBeacon(context))
                    {
                        listener.Configure(9999);
                        listener.Subscribe("H");

                        // this should send one broadcast message and stop
                        speaker.Publish("Hello");
                        Thread.Sleep(10);
                        speaker.Silence();

                        string peerName;
                        string message = listener.ReceiveString(out peerName);

                        Assert.AreEqual("Hello", message);

                        ISocketPollable socket = listener;
                        socket.Socket.Options.ReceiveTimeout = TimeSpan.FromSeconds(2);

                        Assert.Throws <AgainException>(() =>
                        {
                            message = listener.ReceiveString(out peerName);
                        });
                    }
                }
            }
        }
Пример #2
0
        public void Silence()
        {
            using (var speaker = new NetMQBeacon())
                using (var listener = new NetMQBeacon())
                {
                    speaker.Configure(9999);

                    listener.Configure(9999);
                    listener.Subscribe("H");

                    // this should send one broadcast message and stop
                    speaker.Publish("Hello", s_publishInterval);
                    Thread.Sleep(10);
                    speaker.Silence();

                    Assert.AreEqual("Hello", listener.Receive().String);

                    Assert.IsFalse(listener.TryReceive(TimeSpan.FromMilliseconds(300), out BeaconMessage message));
                }
        }
Пример #3
0
        public void Silence()
        {
            using (var speaker = new NetMQBeacon())
            using (var listener = new NetMQBeacon())
            {
                speaker.Configure(9999);

                listener.Configure(9999);
                listener.Subscribe("H");

                // this should send one broadcast message and stop
                speaker.Publish("Hello", s_publishInterval);
                Thread.Sleep(10);
                speaker.Silence();

                Assert.AreEqual("Hello", listener.Receive().String);

                BeaconMessage message;
                Assert.IsFalse(listener.TryReceive(TimeSpan.FromMilliseconds(300), out message));
            }
        }
Пример #4
0
        public void Silence()
        {
            using (var context = NetMQContext.Create())
            using (var speaker = new NetMQBeacon(context))
            using (var listener = new NetMQBeacon(context))
            {
                speaker.Configure(9999);

                listener.Configure(9999);
                listener.Subscribe("H");

                // this should send one broadcast message and stop
                speaker.Publish("Hello");
                Thread.Sleep(10);
                speaker.Silence();

                string peerName;
                string message = listener.ReceiveString(out peerName);

                Assert.AreEqual("Hello", message);

                ISocketPollable socket = listener;
                socket.Socket.Options.ReceiveTimeout = TimeSpan.FromSeconds(2);

                Assert.Throws<AgainException>(() => { message = listener.ReceiveString(out peerName); });
            }
        }