using System;
namespace SharedLibraryCore.RCon
{
public static class StaticHelpers
{
///
/// defines the type of RCon query sent to a server
///
public enum QueryType
{
///
/// retrieve the status of a server
/// does not require RCon password
///
GET_STATUS,
///
/// retrieve the information of a server
/// server responds with key/value pairs
/// RCon password is required
///
GET_INFO,
///
/// retrieve the value of a DVAR
/// RCon password is required
///
GET_DVAR,
///
/// set the value of a DVAR
/// RCon password is required
///
SET_DVAR,
///
/// execute a command
/// RCon password is required
///
COMMAND,
///
/// get the full server command information
/// RCon password is required
///
COMMAND_STATUS
}
///
/// line seperator char included in response from the server
///
public static char SeperatorChar = (char)int.Parse("0a", System.Globalization.NumberStyles.AllowHexSpecifier);
///
/// timeout in seconds to wait for a socket send or receive before giving up
///
public static TimeSpan SocketTimeout(int retryAttempt)
{
return retryAttempt switch
{
1 => TimeSpan.FromMilliseconds(550),
2 => TimeSpan.FromMilliseconds(1000),
3 => TimeSpan.FromMilliseconds(2000),
4 => TimeSpan.FromMilliseconds(5000),
_ => TimeSpan.FromMilliseconds(10000),
};
}
///
/// interval in milliseconds to wait before sending the next RCon request
///
public static readonly int FloodProtectionInterval = 750;
///
/// how many failed connection attempts before aborting connection
///
public static readonly int AllowedConnectionFails = 5;
}
}