Use protocol.abstractions primitives instead of socket abstractions (#1432)

This commit is contained in:
David Fowler 2018-02-10 18:10:09 -08:00 committed by GitHub
parent 01f4bf01cc
commit 94155b0e89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 148 additions and 213 deletions

View File

@ -7,51 +7,52 @@
<BuildBundlerMinifierPackageVersion>2.4.337</BuildBundlerMinifierPackageVersion>
<GoogleProtobufPackageVersion>3.1.0</GoogleProtobufPackageVersion>
<InternalAspNetCoreSdkPackageVersion>2.1.0-preview2-15698</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
<MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion>
<MicrosoftAspNetCoreAuthorizationPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreAuthorizationPackageVersion>
<MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>
<MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>
<MicrosoftAspNetCoreCorsPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreCorsPackageVersion>
<MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>
<MicrosoftAspNetCoreDiagnosticsPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreDiagnosticsPackageVersion>
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreHttpAbstractionsPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreHttpAbstractionsPackageVersion>
<MicrosoftAspNetCoreHttpFeaturesPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreHttpFeaturesPackageVersion>
<MicrosoftAspNetCoreHttpPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreHttpPackageVersion>
<MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreMvcPackageVersion>
<MicrosoftAspNetCoreRoutingPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreRoutingPackageVersion>
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview2-30066</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreServerKestrelPackageVersion>
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreStaticFilesPackageVersion>
<MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreTestHostPackageVersion>
<MicrosoftAspNetCoreTestingPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreTestingPackageVersion>
<MicrosoftAspNetCoreWebSocketsPackageVersion>2.1.0-preview2-30066</MicrosoftAspNetCoreWebSocketsPackageVersion>
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
<MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion>
<MicrosoftAspNetCoreAuthorizationPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreAuthorizationPackageVersion>
<MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreAuthorizationPolicyPackageVersion>
<MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>
<MicrosoftAspNetCoreCorsPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreCorsPackageVersion>
<MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>
<MicrosoftAspNetCoreDiagnosticsPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreDiagnosticsPackageVersion>
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreHttpAbstractionsPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreHttpAbstractionsPackageVersion>
<MicrosoftAspNetCoreHttpFeaturesPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreHttpFeaturesPackageVersion>
<MicrosoftAspNetCoreHttpPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreHttpPackageVersion>
<MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreMvcPackageVersion>
<MicrosoftAspNetCoreProtocolsAbstractionsPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreProtocolsAbstractionsPackageVersion>
<MicrosoftAspNetCoreRoutingPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreRoutingPackageVersion>
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview2-30073</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreServerKestrelPackageVersion>
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreStaticFilesPackageVersion>
<MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreTestHostPackageVersion>
<MicrosoftAspNetCoreTestingPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreTestingPackageVersion>
<MicrosoftAspNetCoreWebSocketsPackageVersion>2.1.0-preview2-30073</MicrosoftAspNetCoreWebSocketsPackageVersion>
<MicrosoftCSharpPackageVersion>4.5.0-preview2-26130-01</MicrosoftCSharpPackageVersion>
<MicrosoftEntityFrameworkCoreDesignPackageVersion>2.1.0-preview2-30066</MicrosoftEntityFrameworkCoreDesignPackageVersion>
<MicrosoftEntityFrameworkCoreSqlServerPackageVersion>2.1.0-preview2-30066</MicrosoftEntityFrameworkCoreSqlServerPackageVersion>
<MicrosoftEntityFrameworkCoreToolsPackageVersion>2.1.0-preview2-30066</MicrosoftEntityFrameworkCoreToolsPackageVersion>
<MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
<MicrosoftExtensionsConfigurationUserSecretsPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsConfigurationUserSecretsPackageVersion>
<MicrosoftExtensionsDependencyInjectionAbstractionsPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsDependencyInjectionAbstractionsPackageVersion>
<MicrosoftExtensionsDependencyInjectionPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsDependencyInjectionPackageVersion>
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
<MicrosoftExtensionsLoggingConfigurationPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsLoggingConfigurationPackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsLoggingConsolePackageVersion>
<MicrosoftExtensionsLoggingDebugPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsLoggingDebugPackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsLoggingTestingPackageVersion>
<MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>
<MicrosoftExtensionsOptionsPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsOptionsPackageVersion>
<MicrosoftExtensionsSecurityHelperSourcesPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsSecurityHelperSourcesPackageVersion>
<MicrosoftExtensionsValueStopwatchSourcesPackageVersion>2.1.0-preview2-30066</MicrosoftExtensionsValueStopwatchSourcesPackageVersion>
<MicrosoftEntityFrameworkCoreDesignPackageVersion>2.1.0-preview2-30073</MicrosoftEntityFrameworkCoreDesignPackageVersion>
<MicrosoftEntityFrameworkCoreSqlServerPackageVersion>2.1.0-preview2-30073</MicrosoftEntityFrameworkCoreSqlServerPackageVersion>
<MicrosoftEntityFrameworkCoreToolsPackageVersion>2.1.0-preview2-30073</MicrosoftEntityFrameworkCoreToolsPackageVersion>
<MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsClosedGenericMatcherSourcesPackageVersion>
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
<MicrosoftExtensionsConfigurationUserSecretsPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsConfigurationUserSecretsPackageVersion>
<MicrosoftExtensionsDependencyInjectionAbstractionsPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsDependencyInjectionAbstractionsPackageVersion>
<MicrosoftExtensionsDependencyInjectionPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsDependencyInjectionPackageVersion>
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsLoggingAbstractionsPackageVersion>
<MicrosoftExtensionsLoggingConfigurationPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsLoggingConfigurationPackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsLoggingConsolePackageVersion>
<MicrosoftExtensionsLoggingDebugPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsLoggingDebugPackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsLoggingTestingPackageVersion>
<MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsObjectMethodExecutorSourcesPackageVersion>
<MicrosoftExtensionsOptionsPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsOptionsPackageVersion>
<MicrosoftExtensionsSecurityHelperSourcesPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsSecurityHelperSourcesPackageVersion>
<MicrosoftExtensionsValueStopwatchSourcesPackageVersion>2.1.0-preview2-30073</MicrosoftExtensionsValueStopwatchSourcesPackageVersion>
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview2-26130-04</MicrosoftNETCoreApp21PackageVersion>
<MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion>
@ -70,7 +71,7 @@
<SystemThreadingChannelsPackageVersion>4.5.0-preview2-26130-01</SystemThreadingChannelsPackageVersion>
<SystemThreadingTasksExtensionsPackageVersion>4.5.0-preview2-26130-01</SystemThreadingTasksExtensionsPackageVersion>
<XunitPackageVersion>2.3.1</XunitPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.3.1</XunitRunnerVisualStudioPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.4.0-beta.1.build3945</XunitRunnerVisualStudioPackageVersion>
</PropertyGroup>
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
</Project>

View File

@ -3,6 +3,7 @@
using System.IO.Pipelines;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Sockets;
namespace FunctionalTests

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO;
using System.IO.Pipelines;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Sockets;
using Microsoft.AspNetCore.Sockets.Features;
@ -23,9 +24,9 @@ namespace SocialWeather
public void OnConnectedAsync(ConnectionContext connection)
{
connection.Metadata["groups"] = new HashSet<string>();
connection.Features.Get<IConnectionMetadataFeature>().Metadata["groups"] = new HashSet<string>();
var format = connection.GetHttpContext().Request.Query["formatType"].ToString();
connection.Metadata["format"] = format;
connection.Features.Get<IConnectionMetadataFeature>().Metadata["format"] = format;
if (string.Equals(format, "protobuf", StringComparison.OrdinalIgnoreCase))
{
var transferModeFeature = connection.Features.Get<ITransferModeFeature>();
@ -47,7 +48,7 @@ namespace SocialWeather
foreach (var connection in _connectionList)
{
var context = connection.GetHttpContext();
var formatter = _formatterResolver.GetFormatter<T>((string)connection.Metadata["format"]);
var formatter = _formatterResolver.GetFormatter<T>((string)connection.Features.Get<IConnectionMetadataFeature>().Metadata["format"]);
var ms = new MemoryStream();
await formatter.WriteAsync(data, ms);
@ -72,7 +73,7 @@ namespace SocialWeather
public void AddGroupAsync(ConnectionContext connection, string groupName)
{
var groups = (HashSet<string>)connection.Metadata["groups"];
var groups = (HashSet<string>)connection.Features.Get<IConnectionMetadataFeature>().Metadata["groups"];
lock (groups)
{
groups.Add(groupName);
@ -81,7 +82,7 @@ namespace SocialWeather
public void RemoveGroupAsync(ConnectionContext connection, string groupName)
{
var groups = (HashSet<string>)connection.Metadata["groups"];
var groups = (HashSet<string>)connection.Features.Get<IConnectionMetadataFeature>().Metadata["groups"];
if (groups != null)
{
lock (groups)

View File

@ -3,7 +3,9 @@
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Sockets;
using Microsoft.AspNetCore.Sockets.Features;
using Microsoft.Extensions.Logging;
namespace SocialWeather
@ -32,7 +34,7 @@ namespace SocialWeather
public async Task ProcessRequests(ConnectionContext connection)
{
var formatter = _formatterResolver.GetFormatter<WeatherReport>(
(string)connection.Metadata["format"]);
(string)connection.Features.Get<IConnectionMetadataFeature>().Metadata["format"]);
while (true)
{

View File

@ -5,7 +5,9 @@ using System.Collections.Generic;
using System.IO.Pipelines;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Sockets;
using Microsoft.AspNetCore.Sockets.Features;
namespace SocketsSample.EndPoints
{
@ -17,7 +19,7 @@ namespace SocketsSample.EndPoints
{
Connections.Add(connection);
await Broadcast($"{connection.ConnectionId} connected ({connection.Metadata[ConnectionMetadataNames.Transport]})");
await Broadcast($"{connection.ConnectionId} connected ({connection.Features.Get<IConnectionMetadataFeature>().Metadata[ConnectionMetadataNames.Transport]})");
try
{
@ -50,7 +52,7 @@ namespace SocketsSample.EndPoints
{
Connections.Remove(connection);
await Broadcast($"{connection.ConnectionId} disconnected ({connection.Metadata[ConnectionMetadataNames.Transport]})");
await Broadcast($"{connection.ConnectionId} disconnected ({connection.Features.Get<IConnectionMetadataFeature>().Metadata[ConnectionMetadataNames.Transport]})");
}
}

View File

@ -3,8 +3,10 @@
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using SocketsSample.Hubs;
namespace SocketsSample
{
@ -23,7 +25,18 @@ namespace SocketsSample
{
factory.AddConsole();
})
.UseKestrel()
.UseKestrel(options =>
{
// Default port
options.ListenLocalhost(5000);
// Hub bound to TCP end point
options.ListenLocalhost(9001, builder =>
{
// Run the hub on this port (this won't work properly until streaming parsing is implemented)
builder.UseHub<Chat>();
});
})
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()

View File

@ -13,6 +13,7 @@ using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.SignalR.Core;
using Microsoft.AspNetCore.SignalR.Internal;
using Microsoft.AspNetCore.SignalR.Internal.Encoders;
@ -64,7 +65,7 @@ namespace Microsoft.AspNetCore.SignalR
public virtual IFeatureCollection Features => _connectionContext.Features;
public virtual IDictionary<object, object> Metadata => _connectionContext.Metadata;
public virtual IDictionary<object, object> Metadata => Features.Get<IConnectionMetadataFeature>().Metadata;
public virtual PipeReader Input => _connectionContext.Transport.Input;

View File

@ -11,10 +11,10 @@ using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.SignalR.Core;
using Microsoft.AspNetCore.SignalR.Internal;
using Microsoft.AspNetCore.SignalR.Internal.Protocol;
using Microsoft.AspNetCore.Sockets;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Internal;
using Microsoft.Extensions.Logging;

View File

@ -1,6 +1,7 @@
// 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 Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Sockets;
using Microsoft.Extensions.DependencyInjection;
@ -8,7 +9,7 @@ namespace Microsoft.AspNetCore.SignalR
{
public static class SignalRSocketBuilderExtensions
{
public static ISocketBuilder UseHub<THub>(this ISocketBuilder socketBuilder) where THub : Hub
public static IConnectionBuilder UseHub<THub>(this IConnectionBuilder socketBuilder) where THub : Hub
{
var endpoint = socketBuilder.ApplicationServices.GetRequiredService<HubEndPoint<THub>>();
return socketBuilder.Run(connection => endpoint.OnConnectedAsync(connection));

View File

@ -6,29 +6,30 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Protocols;
namespace Microsoft.AspNetCore.Sockets
{
public class SocketBuilder : ISocketBuilder
public class ConnectionBuilder : IConnectionBuilder
{
private readonly IList<Func<SocketDelegate, SocketDelegate>> _components = new List<Func<SocketDelegate, SocketDelegate>>();
private readonly IList<Func<ConnectionDelegate, ConnectionDelegate>> _components = new List<Func<ConnectionDelegate, ConnectionDelegate>>();
public IServiceProvider ApplicationServices { get; }
public SocketBuilder(IServiceProvider applicationServices)
public ConnectionBuilder(IServiceProvider applicationServices)
{
ApplicationServices = applicationServices;
}
public ISocketBuilder Use(Func<SocketDelegate, SocketDelegate> middleware)
public IConnectionBuilder Use(Func<ConnectionDelegate, ConnectionDelegate> middleware)
{
_components.Add(middleware);
return this;
}
public SocketDelegate Build()
public ConnectionDelegate Build()
{
SocketDelegate app = features =>
ConnectionDelegate app = features =>
{
return Task.CompletedTask;
};

View File

@ -1,20 +0,0 @@
// 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.Collections.Generic;
using System.IO.Pipelines;
using Microsoft.AspNetCore.Http.Features;
namespace Microsoft.AspNetCore.Sockets
{
public abstract class ConnectionContext
{
public abstract string ConnectionId { get; set; }
public abstract IFeatureCollection Features { get; }
public abstract IDictionary<object, object> Metadata { get; set; }
public abstract IDuplexPipe Transport { get; set; }
}
}

View File

@ -1,49 +0,0 @@
// 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.IO.Pipelines;
namespace Microsoft.AspNetCore.Sockets
{
public class DuplexPipe : IDuplexPipe
{
public DuplexPipe(PipeReader reader, PipeWriter writer)
{
Input = reader;
Output = writer;
}
public PipeReader Input { get; }
public PipeWriter Output { get; }
public void Dispose()
{
}
public static DuplexPipePair CreateConnectionPair(PipeOptions inputOptions, PipeOptions outputOptions)
{
var input = new Pipe(inputOptions);
var output = new Pipe(outputOptions);
var transportToApplication = new DuplexPipe(output.Reader, input.Writer);
var applicationToTransport = new DuplexPipe(input.Reader, output.Writer);
return new DuplexPipePair(applicationToTransport, transportToApplication);
}
// This class exists to work around issues with value tuple on .NET Framework
public struct DuplexPipePair
{
public IDuplexPipe Transport { get; private set; }
public IDuplexPipe Application { get; private set; }
public DuplexPipePair(IDuplexPipe transport, IDuplexPipe application)
{
Transport = transport;
Application = application;
}
}
}
}

View File

@ -1,18 +0,0 @@
// 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 System.Collections.Generic;
using System.Text;
namespace Microsoft.AspNetCore.Sockets
{
public interface ISocketBuilder
{
IServiceProvider ApplicationServices { get; }
ISocketBuilder Use(Func<SocketDelegate, SocketDelegate> middleware);
SocketDelegate Build();
}
}

View File

@ -8,6 +8,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="$(MicrosoftAspNetCoreHttpFeaturesPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Protocols.Abstractions" Version="$(MicrosoftAspNetCoreProtocolsAbstractionsPackageVersion)" />
<PackageReference Include="System.Threading.Channels" Version="$(SystemThreadingChannelsPackageVersion)" />
<PackageReference Include="System.IO.Pipelines" Version="$(SystemIOPipelinesPackageVersion)" />
<PackageReference Include="System.Memory" Version="$(SystemMemoryPackageVersion)" />

View File

@ -3,12 +3,13 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Protocols;
namespace Microsoft.AspNetCore.Sockets
{
public static class SocketBuilderExtensions
{
public static ISocketBuilder Use(this ISocketBuilder socketBuilder, Func<ConnectionContext, Func<Task>, Task> middleware)
public static IConnectionBuilder Use(this IConnectionBuilder socketBuilder, Func<ConnectionContext, Func<Task>, Task> middleware)
{
return socketBuilder.Use(next =>
{
@ -20,7 +21,7 @@ namespace Microsoft.AspNetCore.Sockets
});
}
public static ISocketBuilder Run(this ISocketBuilder socketBuilder, Func<ConnectionContext, Task> middleware)
public static IConnectionBuilder Run(this IConnectionBuilder socketBuilder, Func<ConnectionContext, Task> middleware)
{
return socketBuilder.Use(next =>
{

View File

@ -1,12 +0,0 @@
// 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 System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Sockets
{
public delegate Task SocketDelegate(ConnectionContext connection);
}

View File

@ -1,10 +1,8 @@
// 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 System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Sockets.Http.Features;
namespace Microsoft.AspNetCore.Sockets

View File

@ -10,6 +10,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Sockets.Features;
using Microsoft.AspNetCore.Sockets.Internal;
using Microsoft.AspNetCore.Sockets.Internal.Transports;
@ -32,7 +33,7 @@ namespace Microsoft.AspNetCore.Sockets
_logger = _loggerFactory.CreateLogger<HttpConnectionDispatcher>();
}
public async Task ExecuteAsync(HttpContext context, HttpSocketOptions options, SocketDelegate socketDelegate)
public async Task ExecuteAsync(HttpContext context, HttpSocketOptions options, ConnectionDelegate ConnectionDelegate)
{
// Create the log scope and attempt to pass the Connection ID to it so as many logs as possible contain
// the Connection ID metadata. If this is the negotiate request then the Connection ID for the scope will
@ -53,7 +54,7 @@ namespace Microsoft.AspNetCore.Sockets
else if (HttpMethods.IsGet(context.Request.Method))
{
// GET /{path}
await ExecuteEndpointAsync(context, socketDelegate, options, logScope);
await ExecuteEndpointAsync(context, ConnectionDelegate, options, logScope);
}
else
{
@ -87,7 +88,7 @@ namespace Microsoft.AspNetCore.Sockets
}
}
private async Task ExecuteEndpointAsync(HttpContext context, SocketDelegate socketDelegate, HttpSocketOptions options, ConnectionLogScope logScope)
private async Task ExecuteEndpointAsync(HttpContext context, ConnectionDelegate ConnectionDelegate, HttpSocketOptions options, ConnectionLogScope logScope)
{
var supportedTransports = options.Transports;
@ -119,7 +120,7 @@ namespace Microsoft.AspNetCore.Sockets
// We only need to provide the Input channel since writing to the application is handled through /send.
var sse = new ServerSentEventsTransport(connection.Application.Input, connection.ConnectionId, _loggerFactory);
await DoPersistentConnection(socketDelegate, sse, context, connection);
await DoPersistentConnection(ConnectionDelegate, sse, context, connection);
}
else if (context.WebSockets.IsWebSocketRequest)
{
@ -141,7 +142,7 @@ namespace Microsoft.AspNetCore.Sockets
var ws = new WebSocketsTransport(options.WebSockets, connection.Application, connection, _loggerFactory);
await DoPersistentConnection(socketDelegate, ws, context, connection);
await DoPersistentConnection(ConnectionDelegate, ws, context, connection);
}
else
{
@ -202,7 +203,7 @@ namespace Microsoft.AspNetCore.Sockets
connection.Metadata[ConnectionMetadataNames.Transport] = TransportType.LongPolling;
connection.ApplicationTask = ExecuteApplication(socketDelegate, connection);
connection.ApplicationTask = ExecuteApplication(ConnectionDelegate, connection);
}
else
{
@ -291,7 +292,7 @@ namespace Microsoft.AspNetCore.Sockets
}
}
private async Task DoPersistentConnection(SocketDelegate socketDelegate,
private async Task DoPersistentConnection(ConnectionDelegate ConnectionDelegate,
IHttpTransport transport,
HttpContext context,
DefaultConnectionContext connection)
@ -323,7 +324,7 @@ namespace Microsoft.AspNetCore.Sockets
connection.Status = DefaultConnectionContext.ConnectionStatus.Active;
// Call into the end point passing the connection
connection.ApplicationTask = ExecuteApplication(socketDelegate, connection);
connection.ApplicationTask = ExecuteApplication(ConnectionDelegate, connection);
// Start the transport
connection.TransportTask = transport.ProcessRequestAsync(context, context.RequestAborted);
@ -339,12 +340,12 @@ namespace Microsoft.AspNetCore.Sockets
await _manager.DisposeAndRemoveAsync(connection);
}
private async Task ExecuteApplication(SocketDelegate socketDelegate, ConnectionContext connection)
private async Task ExecuteApplication(ConnectionDelegate ConnectionDelegate, ConnectionContext connection)
{
// Verify some initialization invariants
// We want to be positive that the IConnectionInherentKeepAliveFeature is initialized before invoking the application, if the long polling transport is in use.
Debug.Assert(connection.Metadata[ConnectionMetadataNames.Transport] != null, "Transport has not been initialized yet");
Debug.Assert((TransportType?)connection.Metadata[ConnectionMetadataNames.Transport] != TransportType.LongPolling ||
Debug.Assert(connection.Features.Get<IConnectionMetadataFeature>().Metadata[ConnectionMetadataNames.Transport] != null, "Transport has not been initialized yet");
Debug.Assert((TransportType?)connection.Features.Get<IConnectionMetadataFeature>().Metadata[ConnectionMetadataNames.Transport] != TransportType.LongPolling ||
connection.Features.Get<IConnectionInherentKeepAliveFeature>() != null, "Long-polling transport is in use but IConnectionInherentKeepAliveFeature as not configured");
// Jump onto the thread pool thread so blocking user code doesn't block the setup of the
@ -352,7 +353,7 @@ namespace Microsoft.AspNetCore.Sockets
await AwaitableThreadPool.Yield();
// Running this in an async method turns sync exceptions into async ones
await socketDelegate(connection);
await ConnectionDelegate(connection);
}
private Task ProcessNegotiate(HttpContext context, HttpSocketOptions options, ConnectionLogScope logScope)

View File

@ -5,6 +5,7 @@ using System;
using System.Reflection;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Routing;
namespace Microsoft.AspNetCore.Sockets
@ -20,15 +21,15 @@ namespace Microsoft.AspNetCore.Sockets
_dispatcher = dispatcher;
}
public void MapSocket(string path, Action<ISocketBuilder> socketConfig) =>
public void MapSocket(string path, Action<IConnectionBuilder> socketConfig) =>
MapSocket(new PathString(path), new HttpSocketOptions(), socketConfig);
public void MapSocket(PathString path, Action<ISocketBuilder> socketConfig) =>
public void MapSocket(PathString path, Action<IConnectionBuilder> socketConfig) =>
MapSocket(path, new HttpSocketOptions(), socketConfig);
public void MapSocket(PathString path, HttpSocketOptions options, Action<ISocketBuilder> socketConfig)
public void MapSocket(PathString path, HttpSocketOptions options, Action<IConnectionBuilder> socketConfig)
{
var socketBuilder = new SocketBuilder(_routes.ServiceProvider);
var socketBuilder = new ConnectionBuilder(_routes.ServiceProvider);
socketConfig(socketBuilder);
var socket = socketBuilder.Build();
_routes.MapRoute(path, c => _dispatcher.ExecuteAsync(c, options, socket));

View File

@ -5,6 +5,7 @@ using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using Microsoft.AspNetCore.Protocols;
namespace Microsoft.AspNetCore.Sockets
{

View File

@ -2,12 +2,14 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Buffers;
using System.Collections.Generic;
using System.IO.Pipelines;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Sockets.Features;
using Microsoft.Extensions.Internal;
@ -63,7 +65,7 @@ namespace Microsoft.AspNetCore.Sockets
public ClaimsPrincipal User { get; set; }
public override IDictionary<object, object> Metadata { get; set; } = new ConnectionMetadata();
public IDictionary<object, object> Metadata { get; set; } = new ConnectionMetadata();
public IDuplexPipe Application { get; }

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.AspNetCore.Protocols;
namespace Microsoft.AspNetCore.Sockets
{

View File

@ -1,13 +1,14 @@
// 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 Microsoft.AspNetCore.Protocols;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Sockets
{
public static class SocketBuilderExtensions
{
public static ISocketBuilder UseEndPoint<TEndPoint>(this ISocketBuilder socketBuilder) where TEndPoint : EndPoint
public static IConnectionBuilder UseEndPoint<TEndPoint>(this IConnectionBuilder socketBuilder) where TEndPoint : EndPoint
{
var endpoint = socketBuilder.ApplicationServices.GetRequiredService<TEndPoint>();
// This is a terminal middleware, so there's no need to use the 'next' parameter

View File

@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
public TestClient(bool synchronousCallbacks = false, IHubProtocol protocol = null, IInvocationBinder invocationBinder = null, bool addClaimId = false)
{
var options = new PipeOptions(readerScheduler: synchronousCallbacks ? PipeScheduler.Inline : null);
var pair = Microsoft.AspNetCore.Sockets.DuplexPipe.CreateConnectionPair(options, options);
var pair = DuplexPipe.CreateConnectionPair(options, options);
Connection = new DefaultConnectionContext(Guid.NewGuid().ToString(), pair.Transport, pair.Application);
var claimValue = Interlocked.Increment(ref _id).ToString();

View File

@ -3,6 +3,7 @@
using System.IO.Pipelines;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Sockets;
namespace Microsoft.AspNetCore.SignalR.Tests

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.SignalR.Internal;
using Microsoft.AspNetCore.SignalR.Internal.Protocol;
using Microsoft.AspNetCore.Sockets;

View File

@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Sockets.Features;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@ -116,7 +117,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
context.Request.Query = qs;
SetTransport(context, transportType);
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
await dispatcher.ExecuteAsync(context, new HttpSocketOptions(), app);
@ -151,7 +152,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var qs = new QueryCollection(values);
context.Request.Query = qs;
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
await dispatcher.ExecuteAsync(context, new HttpSocketOptions(), app);
@ -188,7 +189,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var qs = new QueryCollection(values);
context.Request.Query = qs;
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
await dispatcher.ExecuteAsync(context, new HttpSocketOptions(), app);
@ -233,7 +234,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var qs = new QueryCollection(values);
context.Request.Query = qs;
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
@ -268,7 +269,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
SetTransport(context, transportType);
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
await dispatcher.ExecuteAsync(context, new HttpSocketOptions(), app);
@ -297,7 +298,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
context.Request.Path = "/foo";
context.Request.Method = "POST";
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
await dispatcher.ExecuteAsync(context, new HttpSocketOptions(), app);
@ -370,7 +371,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<ImmediatelyCompleteEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<ImmediatelyCompleteEndPoint>();
var app = builder.Build();
await dispatcher.ExecuteAsync(context, new HttpSocketOptions(), app);
@ -396,7 +397,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<SynchronusExceptionEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<SynchronusExceptionEndPoint>();
var app = builder.Build();
await dispatcher.ExecuteAsync(context, new HttpSocketOptions(), app);
@ -422,7 +423,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<ImmediatelyCompleteEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<ImmediatelyCompleteEndPoint>();
var app = builder.Build();
await dispatcher.ExecuteAsync(context, new HttpSocketOptions(), app);
@ -448,7 +449,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<TestEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -474,7 +475,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<ImmediatelyCompleteEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<ImmediatelyCompleteEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -506,7 +507,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<TestEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -545,7 +546,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<TestEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -583,7 +584,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<TestEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -608,7 +609,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<TestEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -643,7 +644,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<BlockingEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<BlockingEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -676,7 +677,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<BlockingEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<BlockingEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -707,7 +708,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<TestEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -751,7 +752,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<ImmediatelyCompleteEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<ImmediatelyCompleteEndPoint>();
var app = builder.Build();
@ -795,7 +796,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var qs = new QueryCollection(values);
context.Request.Query = qs;
var builder = new SocketBuilder(sp);
var builder = new ConnectionBuilder(sp);
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -840,7 +841,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var qs = new QueryCollection(values);
context.Request.Query = qs;
var builder = new SocketBuilder(sp);
var builder = new ConnectionBuilder(sp);
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -892,7 +893,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
context.Request.Query = qs;
context.Response.Body = new MemoryStream();
var builder = new SocketBuilder(sp);
var builder = new ConnectionBuilder(sp);
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -952,7 +953,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
context.Request.Query = qs;
context.Response.Body = new MemoryStream();
var builder = new SocketBuilder(sp);
var builder = new ConnectionBuilder(sp);
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -1030,7 +1031,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
context.Request.Query = qs;
context.Response.Body = new MemoryStream();
var builder = new SocketBuilder(sp);
var builder = new ConnectionBuilder(sp);
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -1086,7 +1087,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
context.Request.Query = qs;
context.Response.Body = new MemoryStream();
var builder = new SocketBuilder(sp);
var builder = new ConnectionBuilder(sp);
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -1116,7 +1117,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var services = new ServiceCollection();
services.AddEndPoint<TestEndPoint>();
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<TestEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();
@ -1196,7 +1197,7 @@ namespace Microsoft.AspNetCore.Sockets.Tests
var qs = new QueryCollection(values);
context.Request.Query = qs;
var builder = new SocketBuilder(services.BuildServiceProvider());
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseEndPoint<ImmediatelyCompleteEndPoint>();
var app = builder.Build();
var options = new HttpSocketOptions();

View File

@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Protocols;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;