mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-27 17:27:55 +03:00
add instance metrics to server
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
@@ -53,12 +54,28 @@ internal static class WebServer
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseCors();
|
||||
app.MapGet("/amnet/info", () => Results.Ok(new SystemState(ApiVersion, Config.GameId, Config.ServerName)));
|
||||
|
||||
app.MapGet("/amnet/info", ServerInfo);
|
||||
app.MapPost("/amnet/signin", ProcessCard);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
private static IResult ServerInfo()
|
||||
{
|
||||
var startedAt = Volatile.Read(ref DllMain.ServerStartedAt);
|
||||
var lastPollAt = Volatile.Read(ref DllMain.LastPollTime);
|
||||
|
||||
var state = new SystemState(
|
||||
ApiVersion,
|
||||
Config.GameId,
|
||||
Config.ServerName,
|
||||
Environment.TickCount64 - startedAt,
|
||||
lastPollAt < 0 ? null : Environment.TickCount64 - lastPollAt);
|
||||
|
||||
return Results.Ok(state);
|
||||
}
|
||||
|
||||
private static async Task ProcessCard(HttpContext ctx)
|
||||
{
|
||||
CardReadRequest request;
|
||||
|
||||
Reference in New Issue
Block a user