mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Code Reorganisation
This commit is contained in:
parent
c153ef4c08
commit
b7c5d591fc
8 changed files with 55 additions and 50 deletions
|
|
@ -232,6 +232,8 @@
|
|||
<Compile Include="Lib\BranchSnapshot.cs" />
|
||||
<Compile Include="Lib\ServerPlayers.cs" />
|
||||
<Compile Include="Lib\ServerProfileSnapshot.cs" />
|
||||
<Compile Include="Lib\ServerStatusUpdate.cs" />
|
||||
<Compile Include="Lib\ServerStatusUpdateRegistration.cs" />
|
||||
<Compile Include="Lib\ViewConverters\EnumDescriptionTypeConverter.cs" />
|
||||
<Compile Include="Lib\ViewConverters\MapNameValueConverter.cs" />
|
||||
<Compile Include="Lib\ViewModel\Engram.cs" />
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ namespace ServerManagerTool.Lib
|
|||
|
||||
public string GetServerLauncherFile() => Path.Combine(this.ProfileSnapshot.InstallDirectory, Config.Default.ServerConfigRelativePath, Config.Default.LauncherFile);
|
||||
|
||||
private void ProcessStatusUpdate(IAsyncDisposable registration, ServerStatusWatcher.ServerStatusUpdate update)
|
||||
private void ProcessStatusUpdate(IAsyncDisposable registration, ServerStatusUpdate update)
|
||||
{
|
||||
if(!Object.ReferenceEquals(registration, this.updateRegistration))
|
||||
{
|
||||
|
|
|
|||
13
src/ARKServerManager/Lib/ServerStatusUpdate.cs
Normal file
13
src/ARKServerManager/Lib/ServerStatusUpdate.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using System.Diagnostics;
|
||||
using ServerManagerTool.Enums;
|
||||
|
||||
namespace ServerManagerTool.Lib
|
||||
{
|
||||
public struct ServerStatusUpdate
|
||||
{
|
||||
public Process Process;
|
||||
public WatcherServerStatus Status;
|
||||
public QueryMaster.ServerInfo ServerInfo;
|
||||
public int OnlinePlayerCount;
|
||||
}
|
||||
}
|
||||
23
src/ARKServerManager/Lib/ServerStatusUpdateRegistration.cs
Normal file
23
src/ARKServerManager/Lib/ServerStatusUpdateRegistration.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using ServerManagerTool.Common.Interfaces;
|
||||
|
||||
namespace ServerManagerTool.Lib
|
||||
{
|
||||
public class ServerStatusUpdateRegistration : IAsyncDisposable
|
||||
{
|
||||
public string InstallDirectory;
|
||||
public IPEndPoint LocalEndpoint;
|
||||
public IPEndPoint SteamEndpoint;
|
||||
public Action<IAsyncDisposable, ServerStatusUpdate> UpdateCallback;
|
||||
public Func<Task> UnregisterAction;
|
||||
|
||||
public string ProfileId;
|
||||
|
||||
public async Task DisposeAsync()
|
||||
{
|
||||
await UnregisterAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
using ServerManagerTool.Common.Interfaces;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
@ -9,44 +7,17 @@ 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
|
||||
{
|
||||
using NLog;
|
||||
using ServerManagerTool;
|
||||
using ServerManagerTool.Common.Utils;
|
||||
using ServerManagerTool.Enums;
|
||||
using StatusCallback = Action<IAsyncDisposable, ServerStatusWatcher.ServerStatusUpdate>;
|
||||
|
||||
public class ServerStatusWatcher
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public struct ServerStatusUpdate
|
||||
{
|
||||
public Process Process;
|
||||
public WatcherServerStatus Status;
|
||||
public QueryMaster.ServerInfo ServerInfo;
|
||||
public int OnlinePlayerCount;
|
||||
}
|
||||
|
||||
private class ServerStatusUpdateRegistration : IAsyncDisposable
|
||||
{
|
||||
public string InstallDirectory;
|
||||
public IPEndPoint LocalEndpoint;
|
||||
public IPEndPoint SteamEndpoint;
|
||||
public StatusCallback UpdateCallback;
|
||||
public Func<Task> UnregisterAction;
|
||||
|
||||
public string AsmId;
|
||||
public string ProfileId;
|
||||
|
||||
public async Task DisposeAsync()
|
||||
{
|
||||
await UnregisterAction();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<ServerStatusUpdateRegistration> _serverRegistrations = new List<ServerStatusUpdateRegistration>();
|
||||
private readonly ActionBlock<Func<Task>> _eventQueue;
|
||||
private readonly Dictionary<string, DateTime> _nextExternalStatusQuery = new Dictionary<string, DateTime>();
|
||||
|
|
@ -72,7 +43,6 @@ namespace ServerManagerTool.Lib
|
|||
{
|
||||
var registration = new ServerStatusUpdateRegistration
|
||||
{
|
||||
AsmId = Config.Default.ServerManagerUniqueKey,
|
||||
InstallDirectory = installDirectory,
|
||||
ProfileId = profileId,
|
||||
LocalEndpoint = localEndpoint,
|
||||
|
|
@ -212,7 +182,7 @@ namespace ServerManagerTool.Lib
|
|||
}
|
||||
}
|
||||
|
||||
private void PostServerStatusUpdate(ServerStatusUpdateRegistration registration, StatusCallback callback, ServerStatusUpdate statusUpdate)
|
||||
private void PostServerStatusUpdate(ServerStatusUpdateRegistration registration, Action<IAsyncDisposable, ServerStatusUpdate> callback, ServerStatusUpdate statusUpdate)
|
||||
{
|
||||
_eventQueue.Post(() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using ServerManagerTool.Enums;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using ServerManagerTool.Enums;
|
||||
|
||||
namespace ServerManagerTool.Lib
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using ServerManagerTool.Common.Interfaces;
|
||||
using System;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using ServerManagerTool.Common.Interfaces;
|
||||
|
||||
namespace ServerManagerTool.Lib
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
using ConanData;
|
||||
using NLog;
|
||||
using ServerManagerTool.Common.Interfaces;
|
||||
using ServerManagerTool.Common.Utils;
|
||||
using ServerManagerTool.Enums;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks.Dataflow;
|
||||
using ConanData;
|
||||
using NLog;
|
||||
using ServerManagerTool.Common.Interfaces;
|
||||
using ServerManagerTool.Common.Utils;
|
||||
using ServerManagerTool.Enums;
|
||||
|
||||
namespace ServerManagerTool.Lib
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue