public ImparterTestService(IChannelFactory imparterChannels) { var commandHandler = new TestCommandHandler(imparterChannels); _incommingCommandsChannel = imparterChannels.GetSubscriberChannel("commands"); _incommingCommandsChannel.Register <TestCommand>(commandHandler.Handle); }
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(); }