mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Server Availability Changes
- moved a few things into the common project.
This commit is contained in:
parent
5c0bbfd0a8
commit
a14f91c412
38 changed files with 393 additions and 461 deletions
|
|
@ -1,4 +1,8 @@
|
|||
using System;
|
||||
using NLog;
|
||||
using ServerManagerTool.Common.Enums;
|
||||
using ServerManagerTool.Common.Utils;
|
||||
using ServerManagerTool.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
|
@ -7,10 +11,6 @@ using System.Net;
|
|||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks.Dataflow;
|
||||
using NLog;
|
||||
using ServerManagerTool.Common.Interfaces;
|
||||
using ServerManagerTool.Common.Utils;
|
||||
using ServerManagerTool.Enums;
|
||||
|
||||
namespace ServerManagerTool.Lib
|
||||
{
|
||||
|
|
@ -45,9 +45,8 @@ namespace ServerManagerTool.Lib
|
|||
{
|
||||
InstallDirectory = installDirectory,
|
||||
ProfileId = profileId,
|
||||
GameFile = gameFile,
|
||||
LocalEndpoint = localEndpoint,
|
||||
SteamEndpoint = steamEndpoint,
|
||||
PublicEndpoint = steamEndpoint,
|
||||
UpdateCallback = updateCallback,
|
||||
};
|
||||
|
||||
|
|
@ -58,7 +57,7 @@ namespace ServerManagerTool.Lib
|
|||
{
|
||||
if(_serverRegistrations.Contains(registration))
|
||||
{
|
||||
Logger.Debug($"{nameof(RegisterForUpdates)} Removing registration for L:{registration.LocalEndpoint} S:{registration.SteamEndpoint}");
|
||||
Logger.Debug($"{nameof(RegisterForUpdates)} Removing registration for L:{registration.LocalEndpoint} P:{registration.PublicEndpoint}");
|
||||
_serverRegistrations.Remove(registration);
|
||||
}
|
||||
tcs.TrySetResult(true);
|
||||
|
|
@ -72,10 +71,10 @@ namespace ServerManagerTool.Lib
|
|||
{
|
||||
if (!_serverRegistrations.Contains(registration))
|
||||
{
|
||||
Logger.Debug($"{nameof(RegisterForUpdates)} Adding registration for L:{registration.LocalEndpoint} S:{registration.SteamEndpoint}");
|
||||
Logger.Debug($"{nameof(RegisterForUpdates)} Adding registration for L:{registration.LocalEndpoint} P:{registration.PublicEndpoint}");
|
||||
_serverRegistrations.Add(registration);
|
||||
|
||||
var registrationKey = registration.SteamEndpoint.ToString();
|
||||
var registrationKey = registration.PublicEndpoint.ToString();
|
||||
_nextExternalStatusQuery[registrationKey] = DateTime.MinValue;
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
|
|
@ -205,7 +204,7 @@ namespace ServerManagerTool.Lib
|
|||
|
||||
private async Task<ServerStatusUpdate> GenerateServerStatusUpdateAsync(ServerStatusUpdateRegistration registration)
|
||||
{
|
||||
var registrationKey = registration.SteamEndpoint.ToString();
|
||||
var registrationKey = registration.PublicEndpoint.ToString();
|
||||
|
||||
//
|
||||
// First check the process status
|
||||
|
|
@ -238,7 +237,7 @@ namespace ServerManagerTool.Lib
|
|||
Logger.Info($"{nameof(GenerateServerStatusUpdateAsync)} Checking server local network status at {registration.LocalEndpoint}");
|
||||
|
||||
// get the server information direct from the server using local connection.
|
||||
GetLocalNetworkStatus(registration.GameFile, registration.LocalEndpoint, out QueryMaster.ServerInfo localInfo, out int onlinePlayerCount);
|
||||
GetLocalNetworkStatus(registration.LocalEndpoint, out QueryMaster.ServerInfo localInfo, out int onlinePlayerCount);
|
||||
|
||||
if (localInfo != null)
|
||||
{
|
||||
|
|
@ -247,10 +246,10 @@ namespace ServerManagerTool.Lib
|
|||
//
|
||||
// Now that it's running, we can check the publication status.
|
||||
//
|
||||
Logger.Info($"{nameof(GenerateServerStatusUpdateAsync)} Checking server public status direct at {registration.SteamEndpoint}");
|
||||
Logger.Info($"{nameof(GenerateServerStatusUpdateAsync)} Checking server public (directly) status at {registration.PublicEndpoint}");
|
||||
|
||||
// get the server information direct from the server using public connection.
|
||||
var serverStatus = CheckServerStatusDirect(registration.SteamEndpoint);
|
||||
var serverStatus = CheckServerStatusDirect(registration.PublicEndpoint);
|
||||
// check if the server returned the information.
|
||||
if (!serverStatus)
|
||||
{
|
||||
|
|
@ -262,11 +261,11 @@ namespace ServerManagerTool.Lib
|
|||
|
||||
if (!string.IsNullOrWhiteSpace(Config.Default.ServerStatusUrlFormat))
|
||||
{
|
||||
Logger.Info($"{nameof(GenerateServerStatusUpdateAsync)} Checking server public status via api at {registration.SteamEndpoint}");
|
||||
Logger.Info($"{nameof(GenerateServerStatusUpdateAsync)} Checking server public (via api) status at {registration.PublicEndpoint}");
|
||||
|
||||
// get the server information direct from the server using external connection.
|
||||
var uri = new Uri(string.Format(Config.Default.ServerStatusUrlFormat, Config.Default.ServerManagerCode, App.Instance.Version, registration.SteamEndpoint.Address, registration.SteamEndpoint.Port));
|
||||
serverStatus = await NetworkUtils.CheckServerStatusViaAPI(uri, registration.SteamEndpoint);
|
||||
var uri = new Uri(string.Format(Config.Default.ServerStatusUrlFormat, Config.Default.ServerManagerCode, App.Instance.Version, registration.PublicEndpoint.Address, registration.PublicEndpoint.Port));
|
||||
serverStatus = await NetworkUtils.CheckServerStatusViaAPI(uri, registration.PublicEndpoint);
|
||||
}
|
||||
|
||||
_nextExternalStatusQuery[registrationKey] = DateTime.Now.AddMilliseconds(Config.Default.ServerStatusWatcher_RemoteStatusQueryDelay);
|
||||
|
|
@ -291,7 +290,7 @@ namespace ServerManagerTool.Lib
|
|||
return await Task.FromResult(statusUpdate);
|
||||
}
|
||||
|
||||
private static bool GetLocalNetworkStatus(string gameFile, IPEndPoint endpoint, out QueryMaster.ServerInfo serverInfo, out int onlinePlayerCount)
|
||||
private static bool GetLocalNetworkStatus(IPEndPoint endpoint, out QueryMaster.ServerInfo serverInfo, out int onlinePlayerCount)
|
||||
{
|
||||
serverInfo = null;
|
||||
onlinePlayerCount = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue