1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-13 08:38:19 -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:
RaidMax
2018-04-02 00:25:06 -05:00
parent 71313b76d9
commit 3e094b0b61
21 changed files with 441 additions and 337 deletions

View File

@ -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)