mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 16:27:23 +01:00
adjust contextaccessor
This commit is contained in:
parent
6da875713f
commit
aebb7fdbb0
2 changed files with 6 additions and 4 deletions
|
|
@ -21,13 +21,15 @@ namespace MareSynchronosServer.Hubs
|
|||
{
|
||||
private readonly SystemInfoService _systemInfoService;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IHttpContextAccessor contextAccessor;
|
||||
private readonly ILogger<MareHub> _logger;
|
||||
private readonly MareDbContext _dbContext;
|
||||
|
||||
public MareHub(MareDbContext mareDbContext, ILogger<MareHub> logger, SystemInfoService systemInfoService, IConfiguration configuration)
|
||||
public MareHub(MareDbContext mareDbContext, ILogger<MareHub> logger, SystemInfoService systemInfoService, IConfiguration configuration, IHttpContextAccessor contextAccessor)
|
||||
{
|
||||
_systemInfoService = systemInfoService;
|
||||
_configuration = configuration;
|
||||
this.contextAccessor = contextAccessor;
|
||||
_logger = logger;
|
||||
_dbContext = mareDbContext;
|
||||
}
|
||||
|
|
@ -81,8 +83,7 @@ namespace MareSynchronosServer.Hubs
|
|||
|
||||
public override Task OnConnectedAsync()
|
||||
{
|
||||
var feature = Context.Features.Get<IHttpContextAccessor>();
|
||||
_logger.LogInformation("Connection from " + feature.GetIpAddress());
|
||||
_logger.LogInformation("Connection from " + contextAccessor.GetIpAddress());
|
||||
MareMetrics.Connections.Inc();
|
||||
return base.OnConnectedAsync();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ namespace MareSynchronosServer
|
|||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddHttpContextAccessor();
|
||||
|
||||
services.AddSignalR(hubOptions =>
|
||||
{
|
||||
hubOptions.MaximumReceiveMessageSize = long.MaxValue;
|
||||
|
|
@ -65,7 +67,6 @@ namespace MareSynchronosServer
|
|||
services.AddHostedService<FileCleanupService>();
|
||||
services.AddHostedService(provider => provider.GetService<SystemInfoService>());
|
||||
services.AddHostedService<DiscordBot>();
|
||||
services.AddHttpContextAccessor();
|
||||
|
||||
services.AddDatabaseDeveloperPageExceptionFilter();
|
||||
services.AddAuthentication(options =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue