Revert "Revert "React to hosting changes""
This reverts commit 12649b19bf.
This commit is contained in:
parent
12649b19bf
commit
df9057a6f7
|
|
@ -6,26 +6,20 @@ using Microsoft.AspNetCore.Hosting;
|
|||
|
||||
namespace Microsoft.AspNetCore.Sockets
|
||||
{
|
||||
public class SocketsApplicationLifetimeEvents : IApplicationLifetimeEvents
|
||||
public class SocketsApplicationLifetimeService : IHostedService
|
||||
{
|
||||
private readonly ConnectionManager _connectionManager;
|
||||
|
||||
public SocketsApplicationLifetimeEvents(ConnectionManager connectionManager)
|
||||
public SocketsApplicationLifetimeService(ConnectionManager connectionManager)
|
||||
{
|
||||
_connectionManager = connectionManager;
|
||||
}
|
||||
|
||||
public void OnApplicationStarted()
|
||||
public void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnApplicationStopped()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnApplicationStopping()
|
||||
public void Stop()
|
||||
{
|
||||
_connectionManager.CloseConnections();
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
{
|
||||
services.AddRouting();
|
||||
services.TryAddSingleton<ConnectionManager>();
|
||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IApplicationLifetimeEvents, SocketsApplicationLifetimeEvents>());
|
||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, SocketsApplicationLifetimeService>());
|
||||
services.TryAddSingleton<PipelineFactory>();
|
||||
services.TryAddSingleton<HttpConnectionDispatcher>();
|
||||
return services;
|
||||
|
|
|
|||
Loading…
Reference in New Issue