static void Main() { // Read in the config and initialise the logging module Config = Config.Load(CONFIG_FILE); Logger = new Logger(Config.LogPath, Config.DisplayVerbosity, Config.LogVerbosity); // Set up module instances Connections = new NetServer(new IPEndPoint(Config.Address, Config.Port), Config.MaxConnections); Authenticator = new ServerAuthenticator( netServer: Connections, serverName: Config.ServerName, serverDescription: Config.ServerDescription, authType: Config.AuthType ); UserManager = new ServerUserManager(Connections, Authenticator, Config.MaxDisplayNameLength); Chat = new ServerChat(Connections, Authenticator, UserManager, Config.ChatHistoryLength); Trading = new ServerTrading(Connections, Authenticator, UserManager); // Add handler for ILoggable modules Authenticator.OnLogEntry += ILoggableHandler; UserManager.OnLogEntry += ILoggableHandler; Chat.OnLogEntry += ILoggableHandler; Trading.OnLogEntry += ILoggableHandler; // Load saved data Authenticator.Load(Config.CredentialDatabasePath); UserManager.Load(Config.UserDatabasePath); Chat.Load(Config.ChatHistoryPath); Trading.Load(Config.TradeDatabasePath); // Start listening for connections Connections.Start(); // State our auth type and where we're listening from Logger.Log(Verbosity.INFO, string.Format("Accepting auth type \"{0}\"", Config.AuthType.ToString())); Logger.Log(Verbosity.INFO, string.Format("Phinix server version {0} listening on {1}:{2}", Version, Connections.Endpoint.Address, Connections.Endpoint.Port)); // Set up an exit condition on SIGINT/Ctrl+C Console.CancelKeyPress += shutdownHandler; // Start interpreting commands CommandInterpreter interpreter = new CommandInterpreter(); while (!exiting) { // Wait until we've got a command to interpret string line = Console.ReadLine(); // Don't do anything if the command is empty if (string.IsNullOrEmpty(line)) { continue; } // Break the line down into the command and its arguments List <string> arguments = new List <string>(line.Split(' ')); string command = arguments.First(); arguments.RemoveAt(0); // Remove the command from the argument list // Check if we've been given the exit command // This is checked here to avoid weird workarounds from the interpreter if (command == "exit" || command == "quit" || command == "stop") { shutdownHandler(); break; } // Interpret the command and its arguments interpreter.Run(command, arguments); } }