initial commit

This commit is contained in:
2025-08-05 14:42:26 +03:00
commit 9907aebe36
29 changed files with 2040 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Engine.Core;
using Engine.Systems.Network;
namespace Server;
public class Endpoints : Behaviour, IFirstFrameUpdate
{
private INetworkCommunicatorServer? server = null!;
public Endpoints()
{
Task.Run(() =>
{
WebApplicationBuilder builder = WebApplication.CreateBuilder();
builder.Services.AddHealthChecks();
WebApplication app = builder.Build();
app.MapHealthChecks("/health");
app.MapGet("/stats", GetStats);
app.Run($"http://0.0.0.0:{Environment.GetEnvironmentVariable("PORT") ?? "8888"}");
});
}
private IResult GetStats() => Results.Json(new { Count = server?.Connections.Count ?? 0 });
public void FirstActiveFrame() => server = Universe.FindRequiredBehaviour<INetworkCommunicatorServer>();
protected override void OnExitedUniverse(IUniverse universe) => server = null;
}