private static string GetInfoText(ServerOptions options) { var infoText = string.Format("Halo Online Server\n" + "Dispatcher port: {0}\n" + "Endpoint port: {1}\n" + "App port: {2}\n" + "Log port: {3}\n" + "Press escape to exit\n\n" + "Connections:\n", options.DispatcherPort, options.EndpointPort, options.AppPort, options.LogPort); return infoText; }
private static void Main(string[] args) { var options = new ServerOptions { DispatcherPort = Settings.Default.DispatcherPort, EndpointHostname = Settings.Default.EndpointHostname, EndpointPort = Settings.Default.EndpointPort, LogPort = Settings.Default.LogPort, AppPort = Settings.Default.AppPort, ClientPort = Settings.Default.ClientPort }; LogListener logListener = new LogListener(options.LogPort, options.ClientPort); ApiSelfHost apiHost = new ApiSelfHost(options); AppSelfHost appHost = new AppSelfHost(options); apiHost.Start(); appHost.Start(); logListener.BeginListen(); FixDebugListeners(); string infoText = GetInfoText(options); bool listen = true; while (listen) { Console.Clear(); Console.Write(infoText); foreach (var connection in logListener.GetConnectionList()) { string connectionState = connection.Connected ? "connected" : "disconnected"; Console.WriteLine("#{0} {1} {2} {3} {4}", connection.Id, connection.ClientId, connection.ClientName, connection.ClientComputerName, connectionState); } if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape) listen = false; Thread.Sleep(100); } appHost.End(); apiHost.End(); logListener.EndListen(); }