You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ApplicationBuilderExtensions.cs 586 B

1234567891011121314151617181920
  1. using Microsoft.AspNetCore.Builder;
  2. using System;
  3. namespace Discord.Relay
  4. {
  5. public static class ApplicationBuilderExtensions
  6. {
  7. public static void UseDiscordRelay(this IApplicationBuilder app, Action<RelayServer> configAction = null)
  8. {
  9. var server = new RelayServer(configAction);
  10. server.StartAsync();
  11. app.Use(async (context, next) =>
  12. {
  13. if (context.WebSockets.IsWebSocketRequest)
  14. await server.AcceptAsync(context);
  15. await next();
  16. });
  17. }
  18. }
  19. }