continuity/Server/AuthorizationServer.cs

55 lines
1.3 KiB
C#
Raw Normal View History

2022-12-31 13:31:30 +00:00
using Microsoft.Extensions.Logging;
using ReInject.Implementation.Attributes;
namespace Server;
using Microsoft.Extensions.Configuration;
public class AuthorizationServer : NetCoreServer.TcpServer
{
2023-01-02 11:25:58 +00:00
private readonly AesProvider _aesProvider;
private readonly ILogger _logger;
2022-12-31 13:31:30 +00:00
2023-01-02 11:25:58 +00:00
public AuthorizationServer(IConfiguration configuration, ILoggerFactory loggerFactory, AesProvider aesProvider) : base(
2022-12-31 13:31:30 +00:00
configuration["auth:address"]!,
configuration.GetValue<int>("auth:port"))
{
2023-01-02 11:25:58 +00:00
_aesProvider = aesProvider;
2022-12-31 13:31:30 +00:00
_logger = loggerFactory.CreateLogger(nameof(AuthorizationServer));
}
protected override NetCoreServer.TcpSession CreateSession()
{
2023-01-02 11:25:58 +00:00
var session = new AuthorizationServerSession(this, _logger, _aesProvider);
return session;
2022-12-31 13:31:30 +00:00
}
protected override void OnStarting()
{
base.OnStarting();
2022-12-31 16:30:13 +00:00
_logger.LogInformation("is starting");
2022-12-31 13:31:30 +00:00
}
protected override void OnStarted()
{
base.OnStarted();
2022-12-31 16:30:13 +00:00
_logger.LogInformation("is started");
2022-12-31 13:31:30 +00:00
}
protected override void OnStopping()
{
base.OnStopping();
2022-12-31 16:30:13 +00:00
_logger.LogInformation("is stopping");
2022-12-31 13:31:30 +00:00
}
protected override void OnStopped()
{
base.OnStopped();
2022-12-31 16:30:13 +00:00
_logger.LogInformation("is stopped");
2022-12-31 13:31:30 +00:00
}
protected override void OnError(System.Net.Sockets.SocketError error)
{
_logger.LogError("Authorization server caught an error with code {error}", error);
}
}