fixed some async startup stuff and made things nicer
This commit is contained in:
parent
5e9b11ed64
commit
00bade57a7
@ -64,43 +64,6 @@ namespace IW4MAdmin
|
||||
|
||||
public void Init()
|
||||
{
|
||||
#region CONFIG
|
||||
var Configs = Directory.EnumerateFiles("config/servers").Where(x => x.Contains(".cfg"));
|
||||
|
||||
if (Configs.Count() == 0)
|
||||
ServerConfigurationGenerator.Generate();
|
||||
|
||||
foreach (var file in Configs)
|
||||
{
|
||||
var Conf = ServerConfiguration.Read(file);
|
||||
var ServerInstance = new IW4MServer(this, Conf);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await ServerInstance.Initialize();
|
||||
Servers.Add(ServerInstance);
|
||||
|
||||
// this way we can keep track of execution time and see if problems arise.
|
||||
var Status = new AsyncStatus(ServerInstance, UPDATE_FREQUENCY);
|
||||
TaskStatuses.Add(Status);
|
||||
|
||||
Logger.WriteVerbose($"Now monitoring {ServerInstance.Hostname}");
|
||||
}
|
||||
|
||||
catch (ServerException e)
|
||||
{
|
||||
Logger.WriteWarning($"Not monitoring server {Conf.IP}:{Conf.Port} due to uncorrectable errors");
|
||||
if (e.GetType() == typeof(DvarException))
|
||||
Logger.WriteError($"Could not get the dvar value for {(e as DvarException).Data["dvar_name"]} (ensure the server has a map loaded)");
|
||||
else if (e.GetType() == typeof(NetworkException))
|
||||
Logger.WriteError(e.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PLUGINS
|
||||
SharedLibrary.Plugins.PluginImporter.Load(this);
|
||||
|
||||
@ -120,6 +83,50 @@ namespace IW4MAdmin
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CONFIG
|
||||
var Configs = Directory.EnumerateFiles("config/servers").Where(x => x.Contains(".cfg"));
|
||||
|
||||
if (Configs.Count() == 0)
|
||||
ServerConfigurationGenerator.Generate();
|
||||
|
||||
foreach (var file in Configs)
|
||||
{
|
||||
var Conf = ServerConfiguration.Read(file);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var ServerInstance = new IW4MServer(this, Conf);
|
||||
await ServerInstance.Initialize();
|
||||
|
||||
lock (Servers)
|
||||
{
|
||||
Servers.Add(ServerInstance);
|
||||
}
|
||||
|
||||
Logger.WriteVerbose($"Now monitoring {ServerInstance.Hostname}");
|
||||
|
||||
// this way we can keep track of execution time and see if problems arise.
|
||||
var Status = new AsyncStatus(ServerInstance, UPDATE_FREQUENCY);
|
||||
lock (TaskStatuses)
|
||||
{
|
||||
TaskStatuses.Add(Status);
|
||||
}
|
||||
}
|
||||
|
||||
catch (ServerException e)
|
||||
{
|
||||
Logger.WriteWarning($"Not monitoring server {Conf.IP}:{Conf.Port} due to uncorrectable errors");
|
||||
if (e.GetType() == typeof(DvarException))
|
||||
Logger.WriteError($"Could not get the dvar value for {(e as DvarException).Data["dvar_name"]} (ensure the server has a map loaded)");
|
||||
else if (e.GetType() == typeof(NetworkException))
|
||||
Logger.WriteError(e.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region COMMANDS
|
||||
if ((ClientDatabase as ClientsDB).GetOwner() == null)
|
||||
Commands.Add(new COwner("owner", "claim ownership of the server", "owner", Player.Permission.User, 0, false));
|
||||
@ -178,17 +185,18 @@ namespace IW4MAdmin
|
||||
{
|
||||
while (Running)
|
||||
{
|
||||
foreach (var Status in TaskStatuses)
|
||||
for (int i = 0; i < TaskStatuses.Count; i++)
|
||||
{
|
||||
var Status = TaskStatuses[i];
|
||||
if (Status.RequestedTask == null || Status.RequestedTask.IsCompleted)
|
||||
{
|
||||
Status.Update(new Task(() => (Status.Dependant as Server).ProcessUpdatesAsync(Status.GetToken())));
|
||||
if (Status.RunAverage > 500)
|
||||
if (Status.RunAverage > 1000)
|
||||
Logger.WriteWarning($"Update task average execution is longer than desired for {(Status.Dependant as Server).GetIP()}::{(Status.Dependant as Server).GetPort()} [{Status.RunAverage}ms]");
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(UPDATE_FREQUENCY);
|
||||
Thread.Sleep(300);
|
||||
}
|
||||
#if !DEBUG
|
||||
foreach (var S in Servers)
|
||||
|
@ -293,6 +293,9 @@ namespace IW4MAdmin
|
||||
|
||||
public override async Task ExecuteEvent(Event E)
|
||||
{
|
||||
if (Throttled)
|
||||
return;
|
||||
|
||||
await ProcessEvent(E);
|
||||
|
||||
foreach (IPlugin P in SharedLibrary.Plugins.PluginImporter.ActivePlugins)
|
||||
@ -341,7 +344,7 @@ namespace IW4MAdmin
|
||||
#endif
|
||||
{
|
||||
|
||||
if ((DateTime.Now - LastPoll).TotalMinutes < 5 && ConnectionErrors > 1)
|
||||
if ((DateTime.Now - LastPoll).TotalMinutes < 2 && ConnectionErrors >= 1)
|
||||
return;
|
||||
|
||||
try
|
||||
@ -349,7 +352,10 @@ namespace IW4MAdmin
|
||||
await PollPlayersAsync();
|
||||
|
||||
if (ConnectionErrors > 0)
|
||||
{
|
||||
Logger.WriteInfo($"Connection has been reestablished with {IP}:{Port}");
|
||||
Throttled = false;
|
||||
}
|
||||
ConnectionErrors = 0;
|
||||
LastPoll = DateTime.Now;
|
||||
}
|
||||
@ -358,7 +364,11 @@ namespace IW4MAdmin
|
||||
{
|
||||
ConnectionErrors++;
|
||||
if (ConnectionErrors == 1)
|
||||
{
|
||||
Logger.WriteError($"{e.Message} {IP}:{Port}, reducing polling rate");
|
||||
Throttled = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
LastMessage = DateTime.Now - start;
|
||||
|
Binary file not shown.
@ -4,6 +4,7 @@ CHANGELOG:
|
||||
-fixed the issue with webfront chat history
|
||||
-fixed console issue of spamming 'polling rate decreased' when server goes offline
|
||||
-'unknown' admin in webfront defaults to 'IW4MAdmin'
|
||||
-streamlined the async server initialization
|
||||
|
||||
|
||||
VERSION 1.3
|
||||
|
@ -60,128 +60,128 @@ Global
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|x64.ActiveCfg = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|x64.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|x86.Build.0 = Release-Stable|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|x64.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|x86.Build.0 = Release-Stable|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|x86.ActiveCfg = Debug|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release|x86.Build.0 = Debug|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|Any CPU.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x64.ActiveCfg = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x64.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x86.Build.0 = Release-Stable|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x86.ActiveCfg = Debug|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x86.Build.0 = Debug|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Any CPU.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x64.ActiveCfg = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x64.Build.0 = Release|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x86.ActiveCfg = Debug|Any CPU
|
||||
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x86.Build.0 = Debug|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|x64.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|x64.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|x86.Build.0 = Release-Stable|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|x86.Build.0 = Release-Stable|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|x86.ActiveCfg = Debug|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release|x86.Build.0 = Debug|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|Any CPU.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x64.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x64.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x86.Build.0 = Release-Stable|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x86.ActiveCfg = Debug|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x86.Build.0 = Debug|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Any CPU.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x64.ActiveCfg = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x64.Build.0 = Release|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x86.ActiveCfg = Debug|Any CPU
|
||||
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x86.Build.0 = Debug|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|x64.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|x64.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|x86.Build.0 = Release-Stable|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|x64.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|x86.Build.0 = Release-Stable|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|x86.ActiveCfg = Debug|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release|x86.Build.0 = Debug|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|Any CPU.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x64.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x64.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x86.Build.0 = Release-Stable|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x86.ActiveCfg = Debug|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x86.Build.0 = Debug|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Any CPU.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x64.ActiveCfg = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x64.Build.0 = Release|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x86.ActiveCfg = Debug|Any CPU
|
||||
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x86.Build.0 = Debug|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|x64.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|x64.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|x86.Build.0 = Release-Stable|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|x64.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|x86.Build.0 = Release-Stable|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|x86.ActiveCfg = Debug|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release|x86.Build.0 = Debug|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|Any CPU.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x64.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x64.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x86.Build.0 = Release-Stable|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x86.ActiveCfg = Debug|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x86.Build.0 = Debug|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Any CPU.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x64.ActiveCfg = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x64.Build.0 = Release|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.ActiveCfg = Debug|Any CPU
|
||||
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.Build.0 = Debug|Any CPU
|
||||
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
@ -217,55 +217,55 @@ Global
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Debug|Any CPU.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Debug|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Debug|x64.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Debug|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Debug|x86.Build.0 = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release|Any CPU.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release|x64.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release|x86.Build.0 = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release|x86.ActiveCfg = Debug|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release|x86.Build.0 = Debug|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|Any CPU.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x64.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x86.Build.0 = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x86.ActiveCfg = Debug|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x86.Build.0 = Debug|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x86.ActiveCfg = Debug|Any CPU
|
||||
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x86.Build.0 = Debug|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|x64.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|x64.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|x86.Build.0 = Release-Stable|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x64.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x86.Build.0 = Release-Stable|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x86.ActiveCfg = Debug|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x86.Build.0 = Debug|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|Any CPU.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x64.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x64.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x86.Build.0 = Release-Stable|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x86.ActiveCfg = Debug|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x86.Build.0 = Debug|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Any CPU.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x64.ActiveCfg = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x64.Build.0 = Release|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x86.ActiveCfg = Debug|Any CPU
|
||||
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x86.Build.0 = Debug|Any CPU
|
||||
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
|
@ -19,7 +19,10 @@ namespace SharedLibrary.Helpers
|
||||
try
|
||||
{
|
||||
var Config = Interfaces.Serialize<Dictionary<string, object>>.Read($"config/{PluginType.ToString()}_{S.ToString()}.cfg");
|
||||
ConfigurationSet.Add(S.ToString(), Config);
|
||||
lock (ConfigurationSet)
|
||||
{
|
||||
ConfigurationSet.Add(S.ToString(), Config);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exceptions.SerializeException)
|
||||
|
@ -22,9 +22,12 @@ namespace SharedLibrary.Network
|
||||
|
||||
static string[] SendQuery(QueryType Type, Server QueryServer, string Parameters = "")
|
||||
{
|
||||
if (QueryServer.Throttled)
|
||||
throw new Exceptions.DvarException("Server is RCON throttled");
|
||||
|
||||
var ServerOOBConnection = new UdpClient();
|
||||
ServerOOBConnection.Client.SendTimeout = 3000;
|
||||
ServerOOBConnection.Client.ReceiveTimeout = 3000;
|
||||
ServerOOBConnection.Client.SendTimeout = 1000;
|
||||
ServerOOBConnection.Client.ReceiveTimeout = 1000;
|
||||
var Endpoint = new IPEndPoint(IPAddress.Parse(QueryServer.GetIP()), QueryServer.GetPort());
|
||||
|
||||
string QueryString = String.Empty;
|
||||
@ -81,7 +84,7 @@ namespace SharedLibrary.Network
|
||||
attempts++;
|
||||
if (attempts > 5)
|
||||
{
|
||||
var e = new Exceptions.NetworkException("Could not communicate with the server (ensure the configuration is correct)");
|
||||
var e = new Exceptions.NetworkException("Could not communicate with the server");
|
||||
e.Data["server_address"] = ServerOOBConnection.Client.RemoteEndPoint.ToString();
|
||||
ServerOOBConnection.Close();
|
||||
throw e;
|
||||
@ -94,6 +97,9 @@ namespace SharedLibrary.Network
|
||||
|
||||
public static async Task<DVAR<T>> GetDvarAsync<T>(this Server server, string dvarName)
|
||||
{
|
||||
if (server.Throttled)
|
||||
throw new Exceptions.DvarException("Server is RCON throttled");
|
||||
|
||||
string[] LineSplit = await Task.FromResult(SendQuery(QueryType.DVAR, server, dvarName));
|
||||
|
||||
if (LineSplit.Length != 3)
|
||||
@ -121,21 +127,29 @@ namespace SharedLibrary.Network
|
||||
|
||||
public static async Task SetDvarAsync(this Server server, string dvarName, object dvarValue)
|
||||
{
|
||||
if (server.Throttled)
|
||||
throw new Exceptions.DvarException("Server is RCON throttled");
|
||||
|
||||
await Task.FromResult(SendQuery(QueryType.DVAR, server, $"set {dvarName} {dvarValue}"));
|
||||
}
|
||||
|
||||
public static async Task<string[]> ExecuteCommandAsync(this Server server, string commandName)
|
||||
{
|
||||
if (server.Throttled)
|
||||
throw new Exceptions.DvarException("Server is RCON throttled");
|
||||
|
||||
return await Task.FromResult(SendQuery(QueryType.COMMAND, server, commandName).Skip(1).ToArray());
|
||||
}
|
||||
|
||||
public static async Task<List<Player>> GetStatusAsync(this Server server)
|
||||
{
|
||||
if (server.Throttled)
|
||||
throw new Exceptions.DvarException("Server is RCON throttled");
|
||||
|
||||
string[] response = await Task.FromResult(SendQuery(QueryType.DVAR, server, "status"));
|
||||
return Utilities.PlayersFromStatus(response);
|
||||
}
|
||||
|
||||
|
||||
static byte[] GetRequestBytes(string Request)
|
||||
{
|
||||
Byte[] initialRequestBytes = Encoding.Unicode.GetBytes(Request);
|
||||
|
@ -370,6 +370,7 @@ namespace SharedLibrary
|
||||
public int MaxClients { get; protected set; }
|
||||
public List<Player> Players { get; protected set; }
|
||||
public string Password { get; private set; }
|
||||
public bool Throttled { get; protected set; }
|
||||
|
||||
// Internal
|
||||
protected string IP;
|
||||
|
Loading…
Reference in New Issue
Block a user