lampac-ukraine/AshdiBase/StatsService.cs
2026-01-30 18:48:54 +02:00

38 lines
1.1 KiB
C#

using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Shared.Engine;
namespace AshdiBase
{
public class StatsService
{
private static string _apiHost = "https://base.lampame.v6.rocks";
private static int _isStatsRequested = 0;
public static async Task StatsAsync(string host)
{
if (Interlocked.CompareExchange(ref _isStatsRequested, 1, 0) == 0)
{
try
{
var jsonContent = "{\"Host\": \"" + host + "\", \"Module\": \"AshdiBase\"}";
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
var result = await Http.BasePost(
$"{_apiHost}/api/collections/Lampac_Ukraine/records",
content);
result.response.EnsureSuccessStatusCode();
}
catch
{
Interlocked.Exchange(ref _isStatsRequested, 0);
}
}
}
}
}