mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-09 23:00:57 -05:00
support custom master url
refactor api instatation to allow custom master url in config
This commit is contained in:
@ -648,85 +648,7 @@ namespace IW4MAdmin.Application
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SendHeartbeat()
|
||||
{
|
||||
bool connected = false;
|
||||
|
||||
while (!_tokenSource.IsCancellationRequested)
|
||||
{
|
||||
if (!connected)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Heartbeat.Send(this, true);
|
||||
connected = true;
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
connected = false;
|
||||
Logger.WriteWarning($"Could not connect to heartbeat server - {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
await Heartbeat.Send(this);
|
||||
}
|
||||
|
||||
catch (System.Net.Http.HttpRequestException e)
|
||||
{
|
||||
Logger.WriteWarning($"Could not send heartbeat - {e.Message}");
|
||||
}
|
||||
|
||||
catch (AggregateException e)
|
||||
{
|
||||
Logger.WriteWarning($"Could not send heartbeat - {e.Message}");
|
||||
var exceptions = e.InnerExceptions.Where(ex => ex.GetType() == typeof(RestEase.ApiException));
|
||||
|
||||
foreach (var ex in exceptions)
|
||||
{
|
||||
if (((RestEase.ApiException)ex).StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
connected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (RestEase.ApiException e)
|
||||
{
|
||||
Logger.WriteWarning($"Could not send heartbeat - {e.Message}");
|
||||
if (e.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
connected = false;
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.WriteWarning($"Could not send heartbeat - {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Delay(30000, _tokenSource.Token);
|
||||
}
|
||||
catch { break; }
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Start()
|
||||
{
|
||||
await Task.WhenAll(new[]
|
||||
{
|
||||
SendHeartbeat(),
|
||||
UpdateServerStates()
|
||||
});
|
||||
}
|
||||
public async Task Start() => await UpdateServerStates();
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
|
Reference in New Issue
Block a user