parent
f48bd8d185
commit
12649b19bf
|
|
@ -6,20 +6,26 @@ using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Sockets
|
namespace Microsoft.AspNetCore.Sockets
|
||||||
{
|
{
|
||||||
public class SocketsApplicationLifetimeService : IHostedService
|
public class SocketsApplicationLifetimeEvents : IApplicationLifetimeEvents
|
||||||
{
|
{
|
||||||
private readonly ConnectionManager _connectionManager;
|
private readonly ConnectionManager _connectionManager;
|
||||||
|
|
||||||
public SocketsApplicationLifetimeService(ConnectionManager connectionManager)
|
public SocketsApplicationLifetimeEvents(ConnectionManager connectionManager)
|
||||||
{
|
{
|
||||||
_connectionManager = connectionManager;
|
_connectionManager = connectionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void OnApplicationStarted()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void OnApplicationStopped()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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<IHostedService, SocketsApplicationLifetimeService>());
|
services.TryAddEnumerable(ServiceDescriptor.Singleton<IApplicationLifetimeEvents, SocketsApplicationLifetimeEvents>());
|
||||||
services.TryAddSingleton<PipelineFactory>();
|
services.TryAddSingleton<PipelineFactory>();
|
||||||
services.TryAddSingleton<HttpConnectionDispatcher>();
|
services.TryAddSingleton<HttpConnectionDispatcher>();
|
||||||
return services;
|
return services;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue