mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 23:31:13 -05:00
tweaked rcon throttle rate/made async
increased cutoff for server overview messages dont print message if timed out
This commit is contained in:
@ -25,7 +25,7 @@ namespace IW4MAdmin
|
||||
{
|
||||
private List<Server> _servers;
|
||||
public List<Server> Servers => _servers.OrderByDescending(s => s.ClientNum).ToList();
|
||||
public Dictionary<int, int> PrivilegedClients { get; set; }
|
||||
public Dictionary<int, Player> PrivilegedClients { get; set; }
|
||||
public ILogger Logger { get; private set; }
|
||||
public bool Running { get; private set; }
|
||||
public EventHandler<Event> ServerEventOccurred { get; private set; }
|
||||
@ -54,7 +54,7 @@ namespace IW4MAdmin
|
||||
ClientSvc = new ClientService();
|
||||
AliasSvc = new AliasService();
|
||||
PenaltySvc = new PenaltyService();
|
||||
PrivilegedClients = new Dictionary<int, int>();
|
||||
PrivilegedClients = new Dictionary<int, Player>();
|
||||
ServerEventOccurred += EventAPI.OnServerEventOccurred;
|
||||
ConfigHandler = new BaseConfigurationHandler<ApplicationConfiguration>("IW4MAdminSettings");
|
||||
}
|
||||
@ -78,13 +78,17 @@ namespace IW4MAdmin
|
||||
{
|
||||
#region DATABASE
|
||||
var ipList = (await ClientSvc.Find(c => c.Level > Player.Permission.Trusted))
|
||||
.Select(c => new { c.IPAddress, c.ClientId });
|
||||
.Select(c => new { c.IPAddress, c.ClientId, c.Level });
|
||||
|
||||
foreach (var a in ipList)
|
||||
{
|
||||
try
|
||||
{
|
||||
PrivilegedClients.Add(a.IPAddress, a.ClientId);
|
||||
PrivilegedClients.Add(a.IPAddress, new Player()
|
||||
{
|
||||
ClientId = a.ClientId,
|
||||
Level = a.Level
|
||||
});
|
||||
}
|
||||
|
||||
catch (ArgumentException)
|
||||
@ -208,7 +212,7 @@ namespace IW4MAdmin
|
||||
Commands.Add(new CIP());
|
||||
Commands.Add(new CMask());
|
||||
Commands.Add(new CPruneAdmins());
|
||||
Commands.Add(new CRestartServer());
|
||||
Commands.Add(new CKillServer());
|
||||
|
||||
foreach (Command C in SharedLibrary.Plugins.PluginImporter.ActiveCommands)
|
||||
Commands.Add(C);
|
||||
@ -238,7 +242,7 @@ namespace IW4MAdmin
|
||||
else
|
||||
{
|
||||
Status.Update(new Task<bool>(() => { return (Status.Dependant as Server).ProcessUpdatesAsync(Status.GetToken()).Result; }));
|
||||
if (Status.RunAverage > 1000 + UPDATE_FREQUENCY)
|
||||
if (Status.RunAverage > 1000 + UPDATE_FREQUENCY && !(Status.Dependant as Server).Throttled)
|
||||
Logger.WriteWarning($"Update task average execution is longer than desired for {(Status.Dependant as Server)} [{Status.RunAverage}ms]");
|
||||
}
|
||||
}
|
||||
|
@ -4,18 +4,18 @@ using System.Threading;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using SharedLibrary;
|
||||
using SharedLibrary.Network;
|
||||
using SharedLibrary.Interfaces;
|
||||
using SharedLibrary.Objects;
|
||||
using System.Text.RegularExpressions;
|
||||
using SharedLibrary.Services;
|
||||
using SharedLibrary.Database.Models;
|
||||
using SharedLibrary.Dtos;
|
||||
using WebfrontCore.Application.Misc;
|
||||
using SharedLibrary.Configuration;
|
||||
|
||||
using WebfrontCore.Application.Misc;
|
||||
|
||||
namespace IW4MAdmin
|
||||
{
|
||||
public class IW4MServer : Server
|
||||
@ -386,7 +386,19 @@ namespace IW4MAdmin
|
||||
async Task<int> PollPlayersAsync()
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var CurrentPlayers = await this.GetStatusAsync();
|
||||
|
||||
List<Player> CurrentPlayers = null;
|
||||
try
|
||||
{
|
||||
CurrentPlayers = await this.GetStatusAsync();
|
||||
}
|
||||
|
||||
// when the server has lost connection
|
||||
catch (SharedLibrary.Exceptions.NetworkException)
|
||||
{
|
||||
Throttled = true;
|
||||
return ClientNum;
|
||||
}
|
||||
#if DEBUG
|
||||
Logger.WriteInfo($"Polling players took {(DateTime.Now - now).TotalMilliseconds}ms");
|
||||
#endif
|
||||
@ -659,7 +671,7 @@ namespace IW4MAdmin
|
||||
//#else
|
||||
}
|
||||
#if DEBUG
|
||||
LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php");
|
||||
//LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php");
|
||||
#endif
|
||||
Logger.WriteInfo($"Log file is {logPath}");
|
||||
#if !DEBUG
|
||||
@ -776,16 +788,20 @@ namespace IW4MAdmin
|
||||
CurrentMap = Maps.Find(m => m.Name == mapname) ?? new Map() { Alias = mapname, Name = mapname };
|
||||
|
||||
// todo: make this more efficient
|
||||
((ApplicationManager)(Manager)).PrivilegedClients = new Dictionary<int, int>();
|
||||
((ApplicationManager)(Manager)).PrivilegedClients = new Dictionary<int, Player>();
|
||||
var ClientSvc = new ClientService();
|
||||
var ipList = (await ClientSvc.Find(c => c.Level > Player.Permission.Trusted))
|
||||
.Select(c => new { c.IPAddress, c.ClientId });
|
||||
.Select(c => new { c.IPAddress, c.ClientId, c.Level });
|
||||
|
||||
foreach (var a in ipList)
|
||||
{
|
||||
try
|
||||
{
|
||||
((ApplicationManager)(Manager)).PrivilegedClients.Add(a.IPAddress, a.ClientId);
|
||||
((ApplicationManager)(Manager)).PrivilegedClients.Add(a.IPAddress, new Player()
|
||||
{
|
||||
ClientId = a.ClientId,
|
||||
Level = a.Level
|
||||
});
|
||||
}
|
||||
|
||||
catch (ArgumentException)
|
||||
|
Reference in New Issue
Block a user