27 lines
868 B
C#
27 lines
868 B
C#
// 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<SocketRouteBuilder> callback)
|
|
{
|
|
var dispatcher = app.ApplicationServices.GetRequiredService<HttpConnectionDispatcher>();
|
|
|
|
var routes = new RouteBuilder(app);
|
|
|
|
callback(new SocketRouteBuilder(routes, dispatcher));
|
|
|
|
app.UseWebSockets();
|
|
app.UseRouter(routes.Build());
|
|
return app;
|
|
}
|
|
}
|
|
}
|