Beispiel #1
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.ProcessExit        += new EventHandler(CurrentDomain_ProcessExit);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            // Migrate settings from previous version if available
            if (MasterServer.Settings.SettingsUpgradeRequired)
            {
                Console.WriteLine("Migrating application settings...");

                MasterServer.Settings.Upgrade();
                MasterServer.Settings.SettingsUpgradeRequired = false;
                MasterServer.Settings.Save();
            }

            // Bind default listen ports if not configured
            if (MasterServer.Settings.ListenPorts == null || MasterServer.Settings.ListenPorts.Count == 0)
            {
                Console.WriteLine("Configuring default listen port...");

                MasterServer.Settings.ListenPorts = new List <ushort>();
                MasterServer.Settings.ListenPorts.Add(Constants.DEFAULT_LISTEN_PORT);
                MasterServer.Settings.Save();
            }

            MasterServer.ListenPorts = "-";

            switch ((args.Length > 0) ? args[0] : null)
            {
            case "console":
                MasterServer.ConsoleMain(args);
                break;

            case "gui":
                MasterServer.GUIMain(args);
                break;

            case "install":
                MasterServerService.InstallService();
                break;

            case "uninstall":
                MasterServerService.UninstallService();
                break;

            default:
                if (ConsoleUtilities.InConsoleSession())
                {
                    MasterServer.ConsoleMain(args);
                }
                else
                {
                    service = new MasterServerService();
                    MasterServerService.ServiceMain(service, args);
                }

                break;
            }
        }