From cf91c97812d518bdfc844d2213a18af364ca738a Mon Sep 17 00:00:00 2001 From: AlessandroCH Date: Tue, 11 Mar 2025 17:12:12 +0100 Subject: [PATCH] server status api --- Campofinale/Http/Dispatch.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Campofinale/Http/Dispatch.cs b/Campofinale/Http/Dispatch.cs index b5df882..6fa4237 100644 --- a/Campofinale/Http/Dispatch.cs +++ b/Campofinale/Http/Dispatch.cs @@ -65,7 +65,17 @@ namespace Campofinale.Http await data(ctx); } + [StaticRoute(HttpServerLite.HttpMethod.GET, "/serverStatus")] + public static async Task serverStatus(HttpContext ctx) + { + string resp = "{\"maxPlayers\":" + Server.config.serverOptions.maxPlayers + ", \"players\":" + Server.clients.Count + ", \"status\":\"Online\"}"; + ctx.Response.StatusCode = 200; + ctx.Response.ContentLength = resp.Length; + ctx.Response.ContentType = "application/json"; + + await ctx.Response.SendAsync(resp); + } [StaticRoute(HttpServerLite.HttpMethod.POST, "/u8/pay/getAllProductList")] public static async Task getAllProductList(HttpContext ctx) {