Esempio n. 1
0
        public ZmqProducer(string endpoint)
        {
            _subscriber = new ZmqSubscriber(endpoint);
            _subscriber.ConnectSocket();

            Background.Produce(new Func <IEnumerable <Stream> >(YieldFromSocket).AsContinuousObservable());
        }
Esempio n. 2
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (!disposing)
     {
         return;
     }
     if (_subscriber == null)
     {
         return;
     }
     _subscriber.Dispose();
     _subscriber = null;
 }
Esempio n. 3
0
        public void Can_send_and_receive_on_messaging_layer()
        {
            var block = new AutoResetEvent(false);

            Task.Factory.StartNew(() =>
            {
                var subscriber = new ZmqSubscriber("tcp://127.0.0.1:5000");
                var next = subscriber.Receive();
                Assert.IsNotNull(next);
                subscriber.Dispose();
                block.Set();
            });

            var publisher = new ZmqPublisher("tcp://127.0.0.1:5000");
            var status = publisher.Send(new byte[1]);
            Assert.AreEqual(SendStatus.Sent, status);

            block.WaitOne();
            publisher.Dispose();
        }