Elisa/Elisa.GameServer/Services/ProxyBackgroundService.cs

26 lines
690 B
C#

namespace Elisa.GameServer.Services;
public class ProxyBackgroundService : BackgroundService
{
readonly ProxyControl proxyControl;
public ProxyBackgroundService(string forwardIpAddress)
{
proxyControl = new ProxyControl(forwardIpAddress);
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
proxyControl.Start();
stoppingToken.Register(() => proxyControl.Stop());
while (!stoppingToken.IsCancellationRequested)
await Task.Delay(1000, stoppingToken);
}
public override async Task StopAsync(CancellationToken stoppingToken)
{
await base.StopAsync(stoppingToken);
}
}