// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Sockets; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Builder { public static class SocketsAppBuilderExtensions { public static IApplicationBuilder UseSockets(this IApplicationBuilder app, Action callback) { var dispatcher = app.ApplicationServices.GetRequiredService(); var routes = new RouteBuilder(app); callback(new SocketRouteBuilder(routes, dispatcher)); app.UseWebSockets(); app.UseRouter(routes.Build()); return app; } } }