Пример #1
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Press Enter to Connect");
            Console.ReadLine( );

            var messageDispatcher = new XDocumentMessageDispatcher();

            messageDispatcher.Register <HeartBeatResponseMessage>(MessageHandler.HandleMessage);
            messageDispatcher.Register <SubmitBasketResponse>(MessageHandler.HandleMessage);


            var endpoint = new IPEndPoint(IPAddress.Loopback, 9000);

            Channel.OnMessage(messageDispatcher.DispatchAsync);
            await Channel.ConnectAsync(endpoint).ConfigureAwait(false);

            _ = Task.Run(HBLoop);

            var basket = new SubmitBasketRequest {
                Id      = "TXN0007",
                POSData = new POSData {
                    Id = "POS001 "
                }
            };
            await Channel.SendAsync(basket).ConfigureAwait(false);

            Console.ReadLine( );
        }
Пример #2
0
 public EchoServer()
 {
     _messageDispatcher.Register <HeartBeatRequestMessage, HeartBeatResponseMessage>(MessageHandler.HandleMessage);
     _messageDispatcher.Register <SubmitBasketRequest, SubmitBasketResponse>(MessageHandler.HandleMessage);
 }