Ejemplo n.º 1
0
        private static void RunInputMode(IChannelFactory channelFactory)
        {
            var service = new ImparterTestService(channelFactory);

            service.Start();

            var commandChannel = channelFactory.GetImparterChannel("commands");

            var eventChannel = channelFactory.GetSubscriberChannel("events");

            eventChannel.Register <TestEvent>(new TestEventHandler().Handle);
            eventChannel.Subscribe();

            while (true)
            {
                var input = Console.ReadLine();
                if (input == "q")
                {
                    break;
                }
                commandChannel.Impart(new TestCommand(input)).GetAwaiter().GetResult();
            }

            eventChannel.Unsubscribe();
            service.Stop();
        }
Ejemplo n.º 2
0
 public TestCommandHandler(IChannelFactory imparterChannels)
 {
     _eventChannel = imparterChannels.GetImparterChannel("events");
 }