Reduce poll rate for servers that have stopped responding to RCON requests.
Actually fixed the extra chat lines on disconnect.
This commit is contained in:
parent
25b3e3abc1
commit
7a81f6c2bd
@ -75,8 +75,8 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
public IDisposable Connect(IDataConsumer channel)
|
public IDisposable Connect(IDataConsumer channel)
|
||||||
{
|
{
|
||||||
channel.OnData(data, null);
|
channel?.OnData(data, null);
|
||||||
channel.OnEnd();
|
channel?.OnEnd();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
public bool OnData(ArraySegment<byte> data, Action continuation)
|
public bool OnData(ArraySegment<byte> data, Action continuation)
|
||||||
{
|
{
|
||||||
buffer.Add(data);
|
buffer?.Add(data);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +346,6 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
foreach (var P in CurrentPlayers)
|
foreach (var P in CurrentPlayers)
|
||||||
await AddPlayer(P);
|
await AddPlayer(P);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long l_size = -1;
|
long l_size = -1;
|
||||||
@ -362,8 +361,24 @@ namespace IW4MAdmin
|
|||||||
#if DEBUG == false
|
#if DEBUG == false
|
||||||
try
|
try
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
|
||||||
|
if ((DateTime.Now - LastPoll).TotalMinutes < 5 && ConnectionErrors > 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
await PollPlayersAsync();
|
await PollPlayersAsync();
|
||||||
|
ConnectionErrors = 0;
|
||||||
|
LastPoll = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(SharedLibrary.Exceptions.NetworkException e)
|
||||||
|
{
|
||||||
|
ConnectionErrors++;
|
||||||
|
if (ConnectionErrors > 1)
|
||||||
|
Logger.WriteError($"{e.Message} {IP}:{Port}, reducing polling rate");
|
||||||
|
}
|
||||||
|
|
||||||
lastMessage = DateTime.Now - start;
|
lastMessage = DateTime.Now - start;
|
||||||
lastCount = DateTime.Now;
|
lastCount = DateTime.Now;
|
||||||
@ -540,7 +555,9 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
ChatHistory.Add(new Chat(E.Origin.Name, "<i>DISCONNECTED</i>", DateTime.Now));
|
ChatHistory.Add(new Chat(E.Origin.Name, "<i>DISCONNECTED</i>", DateTime.Now));
|
||||||
|
|
||||||
if (ClientNum == 0)
|
// the last client hasn't fully disconnected yet
|
||||||
|
// so there will still be at least 1 client left
|
||||||
|
if (ClientNum < 2)
|
||||||
ChatHistory.Clear();
|
ChatHistory.Clear();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -788,11 +805,9 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
override public void initCommands()
|
override public void initCommands()
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (Command C in PluginImporter.potentialCommands)
|
foreach (Command C in PluginImporter.potentialCommands)
|
||||||
Manager.GetCommands().Add(C);
|
Manager.GetCommands().Add(C);
|
||||||
|
|
||||||
|
|
||||||
Manager.GetCommands().Add(new Plugins("plugins", "view all loaded plugins. syntax: !plugins", "p", Player.Permission.Administrator, 0, false));
|
Manager.GetCommands().Add(new Plugins("plugins", "view all loaded plugins. syntax: !plugins", "p", Player.Permission.Administrator, 0, false));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -69,7 +69,7 @@ namespace SharedLibrary.Network
|
|||||||
return SplitResponse;
|
return SplitResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (SocketException)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
attempts++;
|
attempts++;
|
||||||
if (attempts > 5)
|
if (attempts > 5)
|
||||||
@ -131,7 +131,6 @@ namespace SharedLibrary.Network
|
|||||||
|
|
||||||
static byte[] GetRequestBytes(string Request)
|
static byte[] GetRequestBytes(string Request)
|
||||||
{
|
{
|
||||||
|
|
||||||
Byte[] initialRequestBytes = Encoding.Unicode.GetBytes(Request);
|
Byte[] initialRequestBytes = Encoding.Unicode.GetBytes(Request);
|
||||||
Byte[] fixedRequest = new Byte[initialRequestBytes.Length / 2];
|
Byte[] fixedRequest = new Byte[initialRequestBytes.Length / 2];
|
||||||
|
|
||||||
|
@ -171,12 +171,6 @@ namespace SharedLibrary
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Set up the basic variables ( base path / hostname / etc ) that allow the monitor thread to work
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>True if no issues initializing, false otherwise</returns>
|
|
||||||
//abstract public bool intializeBasics();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process any server event
|
/// Process any server event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -422,6 +416,9 @@ namespace SharedLibrary
|
|||||||
public List<Chat> ChatHistory;
|
public List<Chat> ChatHistory;
|
||||||
public Queue<PlayerHistory> playerHistory { get; private set; }
|
public Queue<PlayerHistory> playerHistory { get; private set; }
|
||||||
|
|
||||||
|
protected int ConnectionErrors;
|
||||||
|
protected DateTime LastPoll;
|
||||||
|
|
||||||
//Info
|
//Info
|
||||||
protected String IP;
|
protected String IP;
|
||||||
protected int Port;
|
protected int Port;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user