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