using System; using System.Threading.Tasks; using SteamQueryNet; using SteamQueryNet.Interfaces; namespace ConsoleApp1 { struct server_metrics { public uint openSlots; //NUMOPENPUBCONN } class ArkServer { public string ConnectionInfo { get; } public uint openSlots { get; } public ArkServer(string address) { ConnectionInfo = address; } } class Program { private static string hostname = "join.unfesports.com"; private static ArkServer[] servers = //Todo, make this an arg ... maybe validate hostname, or just pass port. { new ArkServer($"{hostname}:27015"), new ArkServer($"{hostname}:27016"), new ArkServer($"{hostname}:27017"), new ArkServer($"{hostname}:27018"), new ArkServer($"{hostname}:27019") }; static async Task Main(string[] args) { Console.WriteLine("Enumerating Servers"); for (int i = 0; i < 5; ++i) { string myHostAndPort = $"join.unfesports.com:{27015+i}"; IServerQuery serverQuery = new ServerQuery(myHostAndPort); var a = await serverQuery.GetServerInfoAsync(); var b = await serverQuery.GetRulesAsync(); Console.WriteLine($"Map: {a.Map} - {a.Name} - {a.Version}"); server_metrics serverMetrics = new server_metrics(); foreach (var c in b) { if (c.Name == "NUMOPENPUBCONN") { serverMetrics.openSlots = uint.Parse(c.Value); } Console.WriteLine($"{c.Name} / {c.Value}"); } Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(serverMetrics)); } } } }