feat: use activatorutilities to create instance of session
This commit is contained in:
parent
8790b1a3bf
commit
3552134186
3 changed files with 5 additions and 6 deletions
|
@ -8,7 +8,7 @@ namespace Server;
|
|||
|
||||
public abstract class AuthSession : TcpSession
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILogger<AuthSession> _logger;
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
private static readonly byte[] Key = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7 }
|
||||
|
@ -21,7 +21,7 @@ public abstract class AuthSession : TcpSession
|
|||
private readonly ICryptoTransform _decryptor;
|
||||
|
||||
protected AuthSession(TcpServer
|
||||
server, ILogger logger, IMediator mediator) : base(server)
|
||||
server, ILogger<AuthSession> logger, IMediator mediator) : base(server)
|
||||
{
|
||||
_logger = logger;
|
||||
_mediator = mediator;
|
||||
|
|
|
@ -23,9 +23,8 @@ public class WonderkingAuthServer : TcpServer, IHostedService
|
|||
_loggerFactory = loggerFactory;
|
||||
}
|
||||
|
||||
protected override TcpSession CreateSession() => new WonderkingSession(this,
|
||||
_serviceProvider.GetService<IMediator>() ?? throw new InvalidOperationException(),
|
||||
_loggerFactory.CreateLogger(nameof(WonderkingSession)));
|
||||
protected override TcpSession CreateSession() =>
|
||||
ActivatorUtilities.CreateInstance<WonderkingSession>(_serviceProvider, this);
|
||||
|
||||
protected override void OnStarting()
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ public class WonderkingSession : AuthSession
|
|||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
public WonderkingSession(TcpServer server, IMediator mediator, ILogger logger) : base(server, logger, mediator)
|
||||
public WonderkingSession(TcpServer server, IMediator mediator, ILogger<WonderkingSession> logger) : base(server, logger, mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue