mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Availability Changes
- changed Waiting for Publication to more specific Statuses.
This commit is contained in:
parent
a14f91c412
commit
09659d9ae2
20 changed files with 600 additions and 410 deletions
|
|
@ -4,7 +4,8 @@
|
|||
{
|
||||
Unknown,
|
||||
Unavailable,
|
||||
Waiting,
|
||||
Available
|
||||
LocalOnly,
|
||||
PublicOnly,
|
||||
Available,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using NLog;
|
||||
using ServerManagerTool.Common.Lib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -129,45 +128,6 @@ namespace ServerManagerTool.Common.Utils
|
|||
}
|
||||
}
|
||||
|
||||
public static async Task<bool> CheckServerStatusViaAPI(Uri uri, IPEndPoint endpoint)
|
||||
{
|
||||
try
|
||||
{
|
||||
string jsonString;
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
jsonString = await client.DownloadStringTaskAsync(uri);
|
||||
}
|
||||
|
||||
if (jsonString == null)
|
||||
{
|
||||
_logger.Debug($"Server info request returned null string for {endpoint.Address}:{endpoint.Port}");
|
||||
return false;
|
||||
}
|
||||
|
||||
JObject query = JObject.Parse(jsonString);
|
||||
if (query == null)
|
||||
{
|
||||
_logger.Debug($"Server info request failed to parse for {endpoint.Address}:{endpoint.Port} - '{jsonString}'");
|
||||
return false;
|
||||
}
|
||||
|
||||
var available = query.SelectToken("available");
|
||||
if (available == null)
|
||||
{
|
||||
_logger.Debug($"Server at {endpoint.Address}:{endpoint.Port} returned no availability.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool)available;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Debug($"{nameof(CheckServerStatusViaAPI)} - Failed checking status via API for: {endpoint.Address}:{endpoint.Port}. {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task PerformCallToAPIAsync(Uri uri)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue