mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 22:17:22 +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 SystemInfoService _systemInfoService;
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
|
private readonly IHttpContextAccessor contextAccessor;
|
||||||
private readonly ILogger<MareHub> _logger;
|
private readonly ILogger<MareHub> _logger;
|
||||||
private readonly MareDbContext _dbContext;
|
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;
|
_systemInfoService = systemInfoService;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
|
this.contextAccessor = contextAccessor;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_dbContext = mareDbContext;
|
_dbContext = mareDbContext;
|
||||||
}
|
}
|
||||||
|
|
@ -81,8 +83,7 @@ namespace MareSynchronosServer.Hubs
|
||||||
|
|
||||||
public override Task OnConnectedAsync()
|
public override Task OnConnectedAsync()
|
||||||
{
|
{
|
||||||
var feature = Context.Features.Get<IHttpContextAccessor>();
|
_logger.LogInformation("Connection from " + contextAccessor.GetIpAddress());
|
||||||
_logger.LogInformation("Connection from " + feature.GetIpAddress());
|
|
||||||
MareMetrics.Connections.Inc();
|
MareMetrics.Connections.Inc();
|
||||||
return base.OnConnectedAsync();
|
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
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.AddHttpContextAccessor();
|
||||||
|
|
||||||
services.AddSignalR(hubOptions =>
|
services.AddSignalR(hubOptions =>
|
||||||
{
|
{
|
||||||
hubOptions.MaximumReceiveMessageSize = long.MaxValue;
|
hubOptions.MaximumReceiveMessageSize = long.MaxValue;
|
||||||
|
|
@ -65,7 +67,6 @@ namespace MareSynchronosServer
|
||||||
services.AddHostedService<FileCleanupService>();
|
services.AddHostedService<FileCleanupService>();
|
||||||
services.AddHostedService(provider => provider.GetService<SystemInfoService>());
|
services.AddHostedService(provider => provider.GetService<SystemInfoService>());
|
||||||
services.AddHostedService<DiscordBot>();
|
services.AddHostedService<DiscordBot>();
|
||||||
services.AddHttpContextAccessor();
|
|
||||||
|
|
||||||
services.AddDatabaseDeveloperPageExceptionFilter();
|
services.AddDatabaseDeveloperPageExceptionFilter();
|
||||||
services.AddAuthentication(options =>
|
services.AddAuthentication(options =>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue