refactor(battle-node): distinct WS auth status codes + named handler delegate
This commit is contained in:
@@ -51,11 +51,19 @@ public static class BattleNodeExtensions
|
||||
public static IApplicationBuilder UseBattleNode(this IApplicationBuilder app)
|
||||
{
|
||||
app.UseWebSockets();
|
||||
app.Map("/socket.io", branch => branch.Run(async ctx =>
|
||||
{
|
||||
var handler = ctx.RequestServices.GetRequiredService<BattleNodeWebSocketHandler>();
|
||||
await handler.HandleAsync(ctx);
|
||||
}));
|
||||
app.Map("/socket.io", branch => branch.Run(HandleSocketIoAsync));
|
||||
return app;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Terminal handler for <c>/socket.io/*</c> — resolves the singleton
|
||||
/// <see cref="BattleNodeWebSocketHandler"/> from DI and hands the request over.
|
||||
/// Extracted from the inline lambda in <see cref="UseBattleNode"/> so stack traces
|
||||
/// show a real method name during WS connect failures.
|
||||
/// </summary>
|
||||
private static async Task HandleSocketIoAsync(Microsoft.AspNetCore.Http.HttpContext ctx)
|
||||
{
|
||||
var handler = ctx.RequestServices.GetRequiredService<BattleNodeWebSocketHandler>();
|
||||
await handler.HandleAsync(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user