Exemple #1
0
 private void RegisterWebsocket(IApplicationBuilder app)
 {
     app.UseWebSockets(new WebSocketOptions()
     {
         KeepAliveInterval = TimeSpan.FromSeconds(300),
     });
     app.Use(async(context, next) =>
     {
         if (context.WebSockets.IsWebSocketRequest)
         {
             await webSocketService.HandleWebSocketAsync(context, new CancellationTokenSource().Token);
         }
         else
         {
             await next();
         }
     });
 }