//===================================================================================// // Download Config Data via API into Memory // //===================================================================================// public static void QUERY_DATA(string appID) { GameServer_Management.deployment_server.Clear(); //Clear the deployment server list. GameServer_Management.GameServer DeploymentServer = new GameServer_Management.GameServer(); using (var webClient = new System.Net.WebClient()) { var json = webClient.DownloadString("http://phantom-net.duckdns.org:1337/config/" + appID); GameServer_Management Deploy = new GameServer_Management(); Deploy.addDeploymentServer(JObject.Parse(json)); } }
private void comboboxGameserverList_SelectedValueChanged(object sender, EventArgs e) { foreach (JObject gameserver in GameServer_Management.server_collection) { if ((string)gameserver["SERVER_name_friendly"] == comboboxGameserverList.Text) { //Decide what data to pull from the object at this point in time of development. GameServer_Management.GameServer Controlled_GameServer = new GameServer_Management.GameServer(); Controlled_GameServer.DIR_install_location = (string)gameserver["DIR_install_location"]; Controlled_GameServer.DIR_executable = (string)gameserver["DIR_executable"]; Controlled_GameServer.SERVER_launch_arguments = (string)gameserver["SERVER_launch_arguments"]; Controlled_GameServer.SERVER_running_status = (bool)gameserver["SERVER_running_status"]; } } consolePanel.Visible = true; btnStartServer.Visible = true; btnStopServer.Visible = true; chkAutoRestart.Visible = true; lblAutoRestart.Visible = true; }
//===================================================================================// // MANAGEMENT: // //===================================================================================// //Methods that handle management itself. private void btnLoadConfig_Click(object sender, EventArgs e) { foreach (JObject gameserver in GameServer_Management.server_collection) { if ((string)gameserver["SERVER_name_friendly"] == comboboxGameserverList.Text) { GameServer_Management.GameServer Management_Instance = new GameServer_Management.GameServer(); openFileDialog1.InitialDirectory = (string)gameserver["DIR_install_location"] + (string)gameserver["DIR_config"]; } } // Show the dialog and get result. DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) // Test result. { int counter = 0; string line; txtboxConfigOutput.Items.Clear(); //Clear the table try { // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(openFileDialog1.FileName); while ((line = file.ReadLine()) != null) { txtboxConfigOutput.Items.Add(line); counter++; } file.Close(); } catch (IOException) { } } }
private void btnDeployGameserver_Click(object sender, EventArgs e) { //Pull all gameserver data from gameservers.json, split all json strings into a list, iterate through that list for specific data. if (GameServer_Management.server_collection != null) { foreach (JObject gameserver in GameServer_Management.server_collection) { if (txtServerGivenName.Text == (string)gameserver["SERVER_name_friendly"]) { MetroMessageBox.Show(BorealisServerManager.ActiveForm, "Unfortunately, you must give unique names to every server you deploy, using the exact same name would cause several issues.", "Identical gameserver name already exists.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; //Break gracefully out of the entire void function. } } } if (chkSeparateConfig.Checked == true) { MetroMessageBox.Show(BorealisServerManager.ActiveForm, "Unfortunately at this time, deploying instances of gameservers is not supported.", "Deploy New GameServer Instance?", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //Query specific appID for all required data. ServerAPI.QUERY_DATA(ServerAPI.QUERY_STEAM_APPID(dropdownServerSelection.Text)); //Retrieve the data that was just stored into the deployment server list. if (GameServer_Management.deployment_server != null) { //Create a new object to store the deployment data! GameServer_Management.GameServer DeploymentServer = new GameServer_Management.GameServer(); foreach (JObject serverDeploymentData in GameServer_Management.deployment_server) { DeploymentValues.SERVER_type = (string)serverDeploymentData["SERVER_type"]; DeploymentValues.SERVER_launch_arguments = (string)serverDeploymentData["SERVER_launch_arguments"]; DeploymentValues.DIR_executable = (string)serverDeploymentData["DIR_executable"]; DeploymentValues.DIR_config = (string)serverDeploymentData["DIR_config"]; DeploymentValues.DIR_config_file = (string)serverDeploymentData["DIR_config_file"]; DeploymentValues.STEAM_authrequired = (bool)serverDeploymentData["STEAM_authrequired"]; DeploymentValues.STEAM_steamcmd_required = (bool)serverDeploymentData["STEAM_steamcmd_required"]; DeploymentValues.STEAM_workshop_enabled = (bool)serverDeploymentData["STEAM_workshop_enabled"]; DeploymentValues.ENGINE_type = (string)serverDeploymentData["ENGINE_type"]; DeploymentValues.bsm_integration = (string)serverDeploymentData["bsm_integration"]; } } //Determine where to deploy the server based on user input. if (txtboxDestinationFolder.Text == "") { DeploymentValues.DIR_install_location = Environment.CurrentDirectory; } else { DeploymentValues.DIR_install_location = txtboxDestinationFolder.Text; } //Determine whether or not to verify integrity of the installation. if (chkVerifyIntegrity.Value == true) { DeploymentValues.verify_integrity = " +validate"; } else { DeploymentValues.verify_integrity = ""; } switch (DeploymentValues.bsm_integration) { case "none": if (MetroMessageBox.Show(BorealisServerManager.ActiveForm, "Type of GameServer: [" + dropdownServerSelection.Text + "]\n" + "Deploy to: [" + DeploymentValues.DIR_install_location + "]" + "\n\nWARNING: This gameserver currently has NO BSM support.\nYou can deploy it, but BSM cannot configure or control it at this time.", "Deploy GameServer?", MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.Yes) { panelProgress.Visible = true; btnCancelDeployGameserver.Visible = true; btnDeployGameserver.Enabled = false; DeployGameServer(); } break; case "partial": if (MetroMessageBox.Show(BorealisServerManager.ActiveForm, "Type of GameServer: [" + dropdownServerSelection.Text + "]\n" + "Deploy to: [" + DeploymentValues.DIR_install_location + "]" + "\n\nWARNING: This gameserver currently has PARTIAL BSM support.\nYou can deploy it, but BSM can only configure it at this time, you have no ability to control it directly through BSM.", "Deploy GameServer?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { panelProgress.Visible = true; btnCancelDeployGameserver.Visible = true; btnDeployGameserver.Enabled = false; DeployGameServer(); } break; case "full": if (MetroMessageBox.Show(BorealisServerManager.ActiveForm, "Type of GameServer: [" + dropdownServerSelection.Text + "]\n" + "Deploy to: [" + DeploymentValues.DIR_install_location + "]", "Deploy GameServer?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { panelProgress.Visible = true; btnCancelDeployGameserver.Visible = true; btnDeployGameserver.Enabled = false; DeployGameServer(); } break; } } }