コード例 #1
0
        public static void CreateConfigFile(RequesterApplication serverType, bool ovewrite = false)
        {
            string path = ServerConfigPath(serverType);

            Directory.CreateDirectory($@"{Directory.GetCurrentDirectory()}/Config");

            switch (serverType)
            {
            case RequesterApplication.Launcher:
                if (!File.Exists(path) || ovewrite)
                {
                    File.WriteAllText(path, $"{string.Join("\n", LauncherServerHeader)}\n{LoginLobbyFetchServerInformation}");
                }

                if (!File.Exists(GameClientSettingsPath) || ovewrite)
                {
                    File.WriteAllText(GameClientSettingsPath, $"{string.Join("\n", GameClientConfigHeader)}\n{GameClientSettingsInformation}");
                }
                break;

            case RequesterApplication.LoginServer:
                if (!File.Exists(path) || ovewrite)
                {
                    File.WriteAllText(path, $"{string.Join("\n", LoginLobbyServerHeader)}\n{LoginLobbyFetchServerInformation}");
                }

                if (!File.Exists(DatabaseConfigPath) || ovewrite)
                {
                    File.WriteAllText(DatabaseConfigPath, $"{string.Join("\n", DatabaseConfigFileHeader)}\n{DatabaseInformation}");
                }
                break;

            case RequesterApplication.LobbyServer:
                if (!File.Exists(ServerlistPlaceholderPath) || ovewrite)
                {
                    File.WriteAllText(ServerlistPlaceholderPath, $"{string.Join("\n", LoginLobbyServerHeader)}\n{string.Join("", LobbyServerlistPlaceholder)}");
                }

                if (!File.Exists(LobbyServerWhitelistPath) || ovewrite)
                {
                    File.WriteAllText(LobbyServerWhitelistPath, $"{string.Join("\n", WhitelistHeader)}\n{LobbyServerWhitelistInformation}");
                }

                if (!File.Exists(path) || ovewrite)
                {
                    File.WriteAllText(path, $"{string.Join("\n", LoginLobbyServerHeader)}\n{LoginLobbyFetchServerInformation}");
                }
                break;

            case RequesterApplication.GameServer:
                if (!File.Exists(path) || ovewrite)
                {
                    File.WriteAllText(path, $"{string.Join("\n", GameServerHeader)}\n{GameServerInformation}");
                }

                if (!File.Exists(DatabaseConfigPath) || ovewrite)
                {
                    File.WriteAllText(DatabaseConfigPath, $"{string.Join("\n", DatabaseConfigFileHeader)}\n{DatabaseInformation}");
                }
                break;
            }
        }
コード例 #2
0
        public static void LoadConfigFile(RequesterApplication requestApplication)
        {
            string path;

            if (requestApplication == RequesterApplication.EFMigration)
            {
                path = ReadConnectionStringForMigration();
            }
            else
            {
                path = ServerConfigPath(requestApplication);
            }

            if (!File.Exists(path))
            {
                Console.WriteLine($"Configuration{errorMessage}");
                return;
            }

            ConfigServerInformation   csfc = ObjectWrapper.DeserializeCommentedJSONFile <ConfigServerInformation>(path);
            ConfigDatabaseInformation cdi;

            switch (requestApplication)
            {
            case RequesterApplication.Launcher:
                NetworkObjectParameters.LoginServerInformation = csfc.ServerInformationList[0];
                NetworkObjectParameters.LobbyServerInformation = csfc.ServerInformationList[1];
                NetworkObjectParameters.FetchServerInformation = csfc.ServerInformationList[2];
                break;

            case RequesterApplication.EFMigration:
                if (!File.Exists(path))
                {
                    Console.WriteLine($"Database{errorMessage}");
                    return;
                }

                ConfigDatabaseInformation dbInfo = ObjectWrapper.DeserializeCommentedJSONFile <ConfigDatabaseInformation>(path);
                NetworkObjectParameters.DatabaseAddress  = dbInfo.DatabaseAddress;
                NetworkObjectParameters.DatabaseName     = dbInfo.DatabaseName;
                NetworkObjectParameters.DatabaseLogin    = dbInfo.DatabaseLogin;
                NetworkObjectParameters.DatabasePassword = dbInfo.DatabasePassword;
                break;

            case RequesterApplication.LoginServer:
                if (!File.Exists(DatabaseConfigPath))
                {
                    Console.WriteLine($"Database{errorMessage}");
                    return;
                }

                cdi = ObjectWrapper.DeserializeCommentedJSONFile <ConfigDatabaseInformation>(DatabaseConfigPath);
                NetworkObjectParameters.DatabaseAddress        = cdi.DatabaseAddress;
                NetworkObjectParameters.DatabaseName           = cdi.DatabaseName;
                NetworkObjectParameters.DatabaseLogin          = cdi.DatabaseLogin;
                NetworkObjectParameters.DatabasePassword       = cdi.DatabasePassword;
                NetworkObjectParameters.LoginServerInformation = csfc.ServerInformationList[0];
                NetworkObjectParameters.LobbyServerInformation = csfc.ServerInformationList[1];
                NetworkObjectParameters.FetchServerInformation = csfc.ServerInformationList[2];
                break;

            case RequesterApplication.LobbyServer:
                NetworkObjectParameters.LoginServerInformation = csfc.ServerInformationList[0];
                NetworkObjectParameters.LobbyServerInformation = csfc.ServerInformationList[1];
                NetworkObjectParameters.FetchServerInformation = csfc.ServerInformationList[2];

                if (!File.Exists(LobbyServerWhitelistPath))
                {
                    Console.WriteLine($"Lobby's gameserver whitelist{errorMessage}");
                    return;
                }

                ConfigLobbyServerWhitelist gsrwl = ObjectWrapper.DeserializeCommentedJSONFile <ConfigLobbyServerWhitelist>(LobbyServerWhitelistPath);

                NetworkObjectParameters.GameServerRequestIPWhitelist = gsrwl.Whitelist;
                break;

            case RequesterApplication.GameServer:
                NetworkObjectParameters.LobbyServerInformation = csfc.ServerInformationList[0];
                NetworkObjectParameters.GameServerInformation  = csfc.GameServerInformationList[0];

                cdi = ObjectWrapper.DeserializeCommentedJSONFile <ConfigDatabaseInformation>(DatabaseConfigPath);
                NetworkObjectParameters.DatabaseAddress  = cdi.DatabaseAddress;
                NetworkObjectParameters.DatabaseName     = cdi.DatabaseName;
                NetworkObjectParameters.DatabaseLogin    = cdi.DatabaseLogin;
                NetworkObjectParameters.DatabasePassword = cdi.DatabasePassword;
                break;
            }
        }
コード例 #3
0
 private static string ServerConfigPath(RequesterApplication serverType) => $@"{Directory.GetCurrentDirectory()}/Config/{serverType}ServerConfig.json";