// SVSim.BattleNode/Hosting/BattleNodeExtensions.cs using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using SVSim.BattleNode.Bridge; using SVSim.BattleNode.Sessions; namespace SVSim.BattleNode.Hosting; public static class BattleNodeExtensions { public static IServiceCollection AddBattleNode(this IServiceCollection services, Action? configure = null) { var options = new BattleNodeOptions(); configure?.Invoke(options); services.AddSingleton(options); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); return services; } public static IApplicationBuilder UseBattleNode(this IApplicationBuilder app) { app.UseWebSockets(); app.Map("/socket.io", branch => branch.Run(async ctx => { var handler = ctx.RequestServices.GetRequiredService(); await handler.HandleAsync(ctx); })); return app; } }