diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 5065c891b2..0c313a8739 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -104,6 +104,7 @@ + diff --git a/OpenRA.Game/Server/MasterServerQuery.cs b/OpenRA.Game/Server/MasterServerQuery.cs new file mode 100644 index 0000000000..4b09e4cd27 --- /dev/null +++ b/OpenRA.Game/Server/MasterServerQuery.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Net; +using OpenRA.FileFormats; + +namespace OpenRA.Server +{ + static class MasterServerQuery + { + public static IEnumerable GetGameList(string masterServerUrl) + { + var wc = new WebClient(); + var data = wc.DownloadData(masterServerUrl + "list.php"); + var str = Encoding.UTF8.GetString(data); + + var yaml = MiniYaml.FromString(str); + return yaml.Select(a => { var gs = new GameServer(); FieldLoader.Load(gs, a.Value); return gs; }); + } + } + + class GameServer + { + public readonly string Name = null; + public readonly string Address = null; + public readonly int State = 0; + public readonly int Players = 0; + public readonly string Map = null; + public readonly string[] Mods = { }; + public readonly int TTL = 0; + } +}