Exemple #1
0
        public static MyClient Create(NetMQContext context)
        {
            var senderFactory1 = new NetMQSenderFactory("tcp://127.0.0.1:5556", context);
			var senderFactory2 = new NetMQSenderFactory("tcp://127.0.0.1:5557", context);

            var senderManager = SenderManager.Create()
                                             .Route<App1>(senderFactory1)
                                             .Route<App2>(senderFactory2);

            return new MyClient(senderManager, new MessageFactory());
        }
Exemple #2
0
        static void Main(string[] args)
        {
            using (var context = NetMQContext.Create())
            {
                // Setup
                var sender = new NetMQSenderFactory("tcp://127.0.0.1:5556", context);
                var senderManager = SenderManager.Create().Route<object>(sender);

                IClient client = new Client(senderManager, new MessageFactory());

                var random = new Random();

                // Run
                while(true)
                {
                    Thread.Sleep(1000);
                    var baseNumber = random.Next(0, 10000);
                    var response = client.Send<App1RandomNumberResponse, App1RandomNumberRequest>(new App1RandomNumberRequest(baseNumber, baseNumber + random.Next(0, 10000)));
                    Console.WriteLine("Random number response: {0}", response.RandomNumber);
                }
            }
        }