コード例 #1
0
 public Server(string serverEndpoint, int timeOutMilliSecond, string channelEndpoint)
 {
     replyer   = new ZmqReplyer(context, serverEndpoint, timeOutMilliSecond);
     publisher = new ZmqPublisher(context, channelEndpoint);
     orderManager.OnPublicChannelOrderbookUpdated += (s, e) =>
                                                     publisher.Publish(PublicOrderbookKey, e.Message);
     orderManager.OnPublicChannelTradeUpdated += (s, e) =>
                                                 publisher.Publish(PublicTradeKey, e.Message);
     orderManager.OnPrivateMessageUpdated += (s, e) =>
                                             publisher.Publish(GetPrivateOrderKey(e.ClientSecret), e.Message);
 }
コード例 #2
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();
        }