1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2024-10-30 05:42:47 +01:00
Minecraft-Phantom-Panel/Server/Phantom.Server/WebConfigurator.cs
2022-10-07 17:21:39 +02:00

36 lines
1.3 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Phantom.Common.Data.Agent;
using Phantom.Server.Services;
using Phantom.Server.Services.Agents;
using Phantom.Server.Services.Instances;
using Phantom.Server.Services.Rpc;
using WebLauncher = Phantom.Server.Web.Launcher;
namespace Phantom.Server;
sealed class WebConfigurator : WebLauncher.IConfigurator {
private readonly AgentAuthToken agentToken;
private readonly CancellationToken cancellationToken;
public WebConfigurator(AgentAuthToken agentToken, CancellationToken cancellationToken) {
this.agentToken = agentToken;
this.cancellationToken = cancellationToken;
}
public void ConfigureServices(IServiceCollection services) {
services.AddSingleton(new ServiceConfiguration(cancellationToken));
services.AddSingleton(agentToken);
services.AddSingleton<AgentManager>();
services.AddSingleton<AgentJavaRuntimesManager>();
services.AddSingleton<AgentStatsManager>();
services.AddSingleton<InstanceManager>();
services.AddSingleton<InstanceLogManager>();
services.AddSingleton<MessageToServerListenerFactory>();
}
public async Task LoadFromDatabase(IServiceProvider serviceProvider) {
await serviceProvider.GetRequiredService<AgentManager>().Initialize();
await serviceProvider.GetRequiredService<InstanceManager>().Initialize();
}
}