adjust contextaccessor
This commit is contained in:
		| @@ -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 => | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Stanley Dimant
					Stanley Dimant