static void Main(string[] args) { var serverSettings = ServerSettingsHelper.Load(Path.Combine(SettingsFileLocator.LocateConfigurationFolder(), ConfigurationFile)); var consoleLog = new ConsoleLog(); consoleLog.Open(); if (args.Length == 0) { Console.WriteLine("Router was started.\nHere you can see messages it forwards to listeners"); StartProcessorsAndSubscribers(serverSettings); new DemoRouterServer(consoleLog, serverSettings) .Start(); Console.ReadLine(); } else if (args[0] == WorkerArgument) { Console.WriteLine("Worker process.\nType message and press <Enter> to send it to subscribers."); using (var results = new MessageRouterResults(consoleLog, serverSettings.Server)) { while (true) { var text = Console.ReadLine(); if (string.IsNullOrEmpty(text)) { break; } results.SendText(text); } } } else { Console.WriteLine("{0} is started.\nHere you can see messages sent by message router.", args[0]); var config = serverSettings.Listeners.FirstOrDefault(item => item.Name == args[0]); new DemoMessageRouterSubscriber(consoleLog, config) .Start(); } }
public bool Start(WpfServerController controller) { try { var localPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); controller.Model.ServerSettings = ServerSettingsHelper.Load(Path.Combine(SettingsFileLocator.LocateConfigurationFolder(), "MessageRouter.Server.WpfServer.xml")); controller.Model.Router = new WpfRouterServer(controller.Log, controller.Model.ServerSettings); controller.Model.WorkerThread = new Thread(controller.Model.Router.Start); controller.Model.WorkerThread.Start(); return(true); } catch (Exception e) { controller.Log.Error(e); MessageBox.Show(e.ToString(), "Message Router", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } }