Unused variables removed. MasterServer connection updated

This commit is contained in:
EntenKoeniq
2022-03-20 09:21:41 +01:00
parent d64281e582
commit 474cba33fa
11 changed files with 34 additions and 88 deletions

View File

@ -94,7 +94,7 @@ namespace CoopServer
try
{
string data = await httpClient.GetStringAsync("https://wimip.info/json");
string data = await httpClient.GetStringAsync("https://ipinfo.io/json");
info = JsonConvert.DeserializeObject<IpInfo>(data);
}
@ -103,8 +103,6 @@ namespace CoopServer
info = new() { ip = MainNetServer.Configuration.LocalAddress.ToString(), country = "?" };
}
byte errorCounter = 3;
while (!Program.ReadyToStop)
{
string msg =
@ -133,7 +131,7 @@ namespace CoopServer
}
catch (Exception ex)
{
Logging.Error(ex.Message);
Logging.Error($"MasterServer: {ex.Message}");
break;
}
@ -141,21 +139,11 @@ namespace CoopServer
{
Logging.Error($"MasterServer: [{(int)response.StatusCode}]{response.StatusCode}");
if (errorCounter != 0)
{
Logging.Error($"MasterServer: Remaining attempts {errorCounter--} ...");
// Wait 5 seconds before trying again
Thread.Sleep(5000);
continue;
}
break;
// Wait 5 seconds before trying again
Thread.Sleep(5000);
continue;
}
// Reset errorCounter
errorCounter = 3;
// Sleep for 12.5s
Thread.Sleep(12500);
}