// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "FiguraServer v1")); } //app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseWebSockets(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.Use(async(context, next) => { Logger.LogMessage("TEST! " + context.Request.Path + "|" + context.WebSockets.IsWebSocketRequest); if (context.Request.Path == "/connect/" && context.WebSockets.IsWebSocketRequest) { currentConnections++; try { Logger.LogMessage("Accepting websocket. Total connections : " + currentConnections); using (WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync()) { using (var wsc = new WebSocketConnection(webSocket)) { await wsc.Run(); } } } catch (Exception e) { Logger.LogMessage(e); } currentConnections--; Logger.LogMessage("Websocket disposed."); } }); }