IW4M-Admin/SharedLibraryCore/RCon/StaticHelpers.cs

76 lines
2.3 KiB
C#
Raw Normal View History

2018-04-08 02:44:42 -04:00
using System;
2022-01-26 11:32:16 -05:00
using System.Globalization;
2018-04-08 02:44:42 -04:00
namespace SharedLibraryCore.RCon
{
public static class StaticHelpers
{
/// <summary>
2022-01-26 11:32:16 -05:00
/// defines the type of RCon query sent to a server
/// </summary>
public enum QueryType
{
/// <summary>
2022-01-26 11:32:16 -05:00
/// retrieve the status of a server
/// does not require RCon password
/// </summary>
GET_STATUS,
2022-01-26 11:32:16 -05:00
/// <summary>
2022-01-26 11:32:16 -05:00
/// retrieve the information of a server
/// server responds with key/value pairs
/// RCon password is required
/// </summary>
GET_INFO,
2022-01-26 11:32:16 -05:00
/// <summary>
2022-01-26 11:32:16 -05:00
/// retrieve the value of a DVAR
/// RCon password is required
/// </summary>
2019-02-03 21:47:05 -05:00
GET_DVAR,
2022-01-26 11:32:16 -05:00
2019-02-03 21:47:05 -05:00
/// <summary>
2022-01-26 11:32:16 -05:00
/// set the value of a DVAR
/// RCon password is required
2019-02-03 21:47:05 -05:00
/// </summary>
SET_DVAR,
2022-01-26 11:32:16 -05:00
/// <summary>
2022-01-26 11:32:16 -05:00
/// execute a command
/// RCon password is required
/// </summary>
COMMAND,
2022-01-26 11:32:16 -05:00
/// <summary>
2022-01-26 11:32:16 -05:00
/// get the full server command information
/// RCon password is required
/// </summary>
COMMAND_STATUS
}
/// <summary>
2022-01-26 11:32:16 -05:00
/// line seperator char included in response from the server
/// </summary>
2022-01-26 11:32:16 -05:00
public static char SeperatorChar = (char)int.Parse("0a", NumberStyles.AllowHexSpecifier);
/// <summary>
2022-01-26 11:32:16 -05:00
/// interval in milliseconds to wait before sending the next RCon request
/// </summary>
public static readonly int FloodProtectionInterval = 750;
/// <summary>
/// timeout in seconds to wait for a socket send or receive before giving up
/// </summary>
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),
2022-01-26 11:32:16 -05:00
_ => TimeSpan.FromMilliseconds(10000)
};
}
}
2022-01-26 11:32:16 -05:00
}