Discord.Net/experiment/Discord.Net.Relay/ApplicationBuilderExtensions.cs

21 lines
586 B
C#
Raw Permalink Normal View History

2024-06-12 22:47:39 -07:00
using Microsoft.AspNetCore.Builder;
using System;
namespace Discord.Relay
{
public static class ApplicationBuilderExtensions
{
public static void UseDiscordRelay(this IApplicationBuilder app, Action<RelayServer> configAction = null)
{
var server = new RelayServer(configAction);
server.StartAsync();
app.Use(async (context, next) =>
{
if (context.WebSockets.IsWebSocketRequest)
await server.AcceptAsync(context);
await next();
});
}
}
}