// TODO: Cached it!
// See https://learn.microsoft.com/dotnet/api/system.net.http.httpclient.-ctor?view=net-8.0#remarks
HttpClient client = new();
// TODO: make it async.
var infos = client.GetFromJsonAsync<Dictionary<string, int>>("http://api.cncnet.org/status").Result;
if (!infos.TryGetValue(cncnetLiveStatusIdentifier, out int numGames))
numGames = -1;
return numGames;
SYSLIB0014 - Microsoft Learn
Add System.Net.Http.Json package to polyfill
GetFromJsonAsync
methods.like this:
https://github.com/CnCNet/xna-cncnet-client/blob/f89c8fcdb0008bac7b7e205d561544e000340373/DXMainClient/Domain/Multiplayer/CnCNet/CnCNetPlayerCountTask.cs#L53-L80
TODO