private void comboboxGameserverList_SelectedValueChanged(object sender, EventArgs e) { var currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text); var process = ProcessManager.GetProcessByNickname(currentServer.SERVER_name_friendly); var isRunning = process?.IsRunning ?? false; if (isRunning) { btnStartServer.Enabled = false; chkAutoRestart.Enabled = false; lblAutoRestart.Enabled = false; //lblRedirectInOut.Enabled = false; //chkRedirectInOut.Enabled = false; btnStopServer.Enabled = true; } else { btnStartServer.Enabled = true; chkAutoRestart.Enabled = true; lblAutoRestart.Enabled = true; //lblRedirectInOut.Enabled = true; //chkRedirectInOut.Enabled = true; btnStopServer.Enabled = false; } SubscribeToProcess(process); return; }
private void btnSendCommand_Click(object sender, EventArgs e) { var currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text); consoleOutputList.Items.Add("Command Issued to Server: " + txtboxIssueCommand.Text); ProcessManager.GetProcessByNickname(currentServer.SERVER_name_friendly)?.WriteLine(txtboxIssueCommand.Text); txtboxIssueCommand.Text = ""; }
private void btnStopServer_Click(object senders, EventArgs e) { btnStopServer.Enabled = false; btnStartServer.Enabled = true; chkAutoRestart.Enabled = true; lblAutoRestart.Enabled = true; //chkRedirectInOut.Enabled = true; //lblRedirectInOut.Enabled = true; txtboxIssueCommand.Text = " > Server is Not Running"; txtboxIssueCommand.Enabled = false; var currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text); ProcessManager.GetProcessByNickname(currentServer.SERVER_name_friendly)?.Stop(); }
public void RefreshData() { //Pull all gameserver data from gameservers.json, split all json strings into a list, iterate through that list for specific data. if (GameServerManagement.ServerCollection != null) { if (GameServerManagement.ServerCollection.Count != 0) { overallServerStatsGrid.Rows.Clear(); foreach (GameServerObject gameserver in GameServerManagement.ServerCollection) { var isRunning = ProcessManager.GetProcessByNickname(gameserver.SERVER_name_friendly)?.IsRunning ?? false; overallServerStatsGrid.Rows.Add(gameserver.SERVER_name_friendly, gameserver.SERVER_type, "0.0GB", "0.0GB", "0.0%", "0 Kb/s", isRunning, "No"); } overallServerStatsGrid.Visible = true; //Show Table only if values have been added. } else { overallServerStatsGrid.Visible = false; //Hide Table } } }
//===================================================================================// // SERVER CONTROL: // //===================================================================================// private void btnStartServer_Click(object sender, EventArgs e) { var currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text); //These strings tell the process manager how exactly to start the server processes based on the engine they use. string engineSpecificDirectory = null; string engineSpecificArguments = null; switch (currentServer.ENGINE_type) { case "SOURCE": //Copy SRCDS Redirection utility (Band-Aid Redirection Fix) into working gameserver.DIR_root directory. string fileName = "SrcdsConRedirect.exe"; string sourcePath = Environment.CurrentDirectory; string targetPath = currentServer.DIR_install_location + @"\steamapps\common" + currentServer.DIR_root; // Use Path class to manipulate file and directory paths. string sourceFile = System.IO.Path.Combine(sourcePath, fileName); string destFile = System.IO.Path.Combine(targetPath, fileName); // Create a new target folder, if necessary. if (!System.IO.Directory.Exists(targetPath)) { System.IO.Directory.CreateDirectory(targetPath); } // overwrite the destination file if it already exists. System.IO.File.Copy(sourceFile, destFile, true); engineSpecificDirectory = currentServer.DIR_install_location + @"\steamapps\common" + currentServer.DIR_root + @"\SrcdsConRedirect.exe"; engineSpecificArguments = $"-console {currentServer.SERVER_launch_arguments} +port {currentServer.SERVER_port} +map {currentServer.GAME_map} +maxplayers {currentServer.GAME_maxplayers}"; break; case "UNREAL": engineSpecificDirectory = currentServer.DIR_install_location + @"\steamapps\common" + currentServer.DIR_root + currentServer.SERVER_executable; engineSpecificArguments = string.Format("{0}{1}?maxplayers={3}", currentServer.GAME_map, currentServer.SERVER_launch_arguments, currentServer.GAME_maxplayers); break; case "GENERIC": engineSpecificDirectory = currentServer.DIR_install_location + currentServer.DIR_root + currentServer.SERVER_executable; engineSpecificArguments = currentServer.SERVER_launch_arguments; break; } if (chkRedirectInOut.Value) { //CREATE THE PROCESS var process = ProcessManager.GetOrCreate(currentServer.SERVER_name_friendly, engineSpecificDirectory, engineSpecificArguments, new ProcessLaunchOptions { ShowWindowOnStart = false }); //Start the Process! SubscribeToProcess(process); ProcessManager.GetProcessByNickname(currentServer.SERVER_name_friendly)?.Start(); } else { //CREATE THE PROCESS var process = ProcessManager.GetOrCreate(currentServer.SERVER_name_friendly, engineSpecificDirectory, engineSpecificArguments, new ProcessLaunchOptions { ShowWindowOnStart = true }); //Start the Process! SubscribeToProcess(process); ProcessManager.GetProcessByNickname(currentServer.SERVER_name_friendly)?.Start(); } btnStartServer.Enabled = false; btnStopServer.Enabled = true; txtboxIssueCommand.Enabled = true; txtboxIssueCommand.Text = ""; //chkRedirectInOut.Enabled = false; //lblRedirectInOut.Enabled = false; }