From 448eaa97a792f34811dd025d7004af423b4d7710 Mon Sep 17 00:00:00 2001 From: Riley S Date: Mon, 8 Mar 2021 02:48:49 -0500 Subject: [PATCH] inital --- ArkStatusMonitor/ArkStatusMonitor.csproj | 14 ++++++ ArkStatusMonitor/Program.cs | 61 ++++++++++++++++++++++++ TestProject.sln | 16 +++++++ 3 files changed, 91 insertions(+) create mode 100644 ArkStatusMonitor/ArkStatusMonitor.csproj create mode 100644 ArkStatusMonitor/Program.cs create mode 100644 TestProject.sln diff --git a/ArkStatusMonitor/ArkStatusMonitor.csproj b/ArkStatusMonitor/ArkStatusMonitor.csproj new file mode 100644 index 0000000..e8db78d --- /dev/null +++ b/ArkStatusMonitor/ArkStatusMonitor.csproj @@ -0,0 +1,14 @@ + + + + Exe + net5.0 + ConsoleApp1 + + + + + + + + diff --git a/ArkStatusMonitor/Program.cs b/ArkStatusMonitor/Program.cs new file mode 100644 index 0000000..df35bb5 --- /dev/null +++ b/ArkStatusMonitor/Program.cs @@ -0,0 +1,61 @@ +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)); + } + + } + } +} \ No newline at end of file diff --git a/TestProject.sln b/TestProject.sln new file mode 100644 index 0000000..116ff3d --- /dev/null +++ b/TestProject.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArkStatusMonitor", "ArkStatusMonitor\ArkStatusMonitor.csproj", "{93538365-4FAC-4674-9A30-95DECDD27E47}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {93538365-4FAC-4674-9A30-95DECDD27E47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93538365-4FAC-4674-9A30-95DECDD27E47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93538365-4FAC-4674-9A30-95DECDD27E47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93538365-4FAC-4674-9A30-95DECDD27E47}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal