public void UpdateServerList() { serverList = Php.getServers(); String[] s = serverList.ServerToStrings(); tot = Union(s, uptext); servers.SetMenuItems(tot); }
public static ServerList getServers() { String tableString = Php.formatString(); if (tableString != "") { List <string> ip = new List <string>(); List <Int32> max = new List <Int32>(); List <Int32> openSlots = new List <Int32>(); List <Int32> ping = new List <Int32>(); const string SERVER_VALID_DATA_HEADER = "SERVER_"; String rows = tableString.Trim().Substring(SERVER_VALID_DATA_HEADER.Length); String[] words = Regex.Split(rows, "_ROW_"); foreach (string word in words) { String[] cols = Regex.Split(word, "_COL_"); if (cols.Length == 4) { String temp = cols[0].Trim(); if (temp.Equals(Functions.MyIp())) { ip.Add("localhost"); } else { ip.Add(temp); } max.Add(Convert.ToInt32(cols[1].Trim())); openSlots.Add(Convert.ToInt32(cols[2].Trim())); ping.Add(Convert.ToInt32(cols[3].Trim())); } } ServerList sL = new ServerList(ip, max, openSlots, ping); return(sL); } else { return(null); } }
public static void ReadCommands() { String[] all_Commands = new String[4]; all_Commands[0] = "all_commands : Writes a list of all commands"; all_Commands[1] = "start_client : Start a client that connects to the server"; all_Commands[2] = "kill_client : Ending all open clients"; all_Commands[3] = "other : List of all avaiable servers"; command = Console.ReadLine(); if (command.Equals("start_client")) { System.Console.WriteLine("Starting client!"); Functions.RunClientFromServer(); } else if (command.Equals("kill_client")) { System.Console.WriteLine("Ending client-process!"); Functions.EndClient(); } else if (command.Equals("all_commands")) { Console.WriteLine("\n"); for (int i = 0; i < all_Commands.Length; i++) { Console.WriteLine(all_Commands[i]); } } else if (command.Equals("other")) { sL = Php.getServers(); sL.getIp(); } else { System.Console.WriteLine("Unknown command! \n Write all_commands to see commands"); } }
public static ServerList getServers() { String tableString = Php.formatString(); if (tableString != "") { List<string> ip = new List<string>(); List<Int32> max = new List<Int32>(); List<Int32> openSlots = new List<Int32>(); List<Int32> ping = new List<Int32>(); const string SERVER_VALID_DATA_HEADER = "SERVER_"; String rows = tableString.Trim().Substring(SERVER_VALID_DATA_HEADER.Length); String[] words = Regex.Split(rows, "_ROW_"); foreach (string word in words) { String[] cols = Regex.Split(word, "_COL_"); if (cols.Length == 4) { String temp = cols[0].Trim(); if(temp.Equals(Functions.MyIp())) { ip.Add("localhost"); } else { ip.Add(temp); } max.Add(Convert.ToInt32(cols[1].Trim())); openSlots.Add(Convert.ToInt32(cols[2].Trim())); ping.Add(Convert.ToInt32(cols[3].Trim())); } } ServerList sL = new ServerList(ip, max, openSlots, ping); return sL; } else return null; }