2018-04-08 02:44:42 -04:00
|
|
|
|
using System;
|
2018-04-02 01:25:06 -04:00
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
namespace SharedLibraryCore.RCon
|
2018-04-02 01:25:06 -04:00
|
|
|
|
{
|
|
|
|
|
public static class StaticHelpers
|
|
|
|
|
{
|
2018-09-07 23:29:42 -04:00
|
|
|
|
/// <summary>
|
2022-01-26 11:32:16 -05:00
|
|
|
|
/// defines the type of RCon query sent to a server
|
2018-09-07 23:29:42 -04:00
|
|
|
|
/// </summary>
|
2018-04-02 01:25:06 -04:00
|
|
|
|
public enum QueryType
|
|
|
|
|
{
|
2018-09-07 23:29:42 -04:00
|
|
|
|
/// <summary>
|
2022-01-26 11:32:16 -05:00
|
|
|
|
/// retrieve the status of a server
|
|
|
|
|
/// does not require RCon password
|
2018-09-07 23:29:42 -04:00
|
|
|
|
/// </summary>
|
2018-04-02 01:25:06 -04:00
|
|
|
|
GET_STATUS,
|
2022-01-26 11:32:16 -05:00
|
|
|
|
|
2018-09-07 23:29:42 -04: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
|
2018-09-07 23:29:42 -04:00
|
|
|
|
/// </summary>
|
2018-04-02 01:25:06 -04:00
|
|
|
|
GET_INFO,
|
2022-01-26 11:32:16 -05:00
|
|
|
|
|
2018-09-07 23:29:42 -04:00
|
|
|
|
/// <summary>
|
2022-01-26 11:32:16 -05:00
|
|
|
|
/// retrieve the value of a DVAR
|
|
|
|
|
/// RCon password is required
|
2018-09-07 23:29:42 -04:00
|
|
|
|
/// </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
|
|
|
|
|
2018-09-07 23:29:42 -04:00
|
|
|
|
/// <summary>
|
2022-01-26 11:32:16 -05:00
|
|
|
|
/// execute a command
|
|
|
|
|
/// RCon password is required
|
2018-09-07 23:29:42 -04:00
|
|
|
|
/// </summary>
|
2018-04-02 01:25:06 -04:00
|
|
|
|
COMMAND,
|
2022-01-26 11:32:16 -05:00
|
|
|
|
|
2019-02-09 16:35:13 -05:00
|
|
|
|
/// <summary>
|
2022-01-26 11:32:16 -05:00
|
|
|
|
/// get the full server command information
|
|
|
|
|
/// RCon password is required
|
2019-02-09 16:35:13 -05:00
|
|
|
|
/// </summary>
|
|
|
|
|
COMMAND_STATUS
|
2018-04-02 01:25:06 -04:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 11:32:16 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// timeout in seconds to wait for a socket send or receive before giving up
|
2018-09-07 23:29:42 -04:00
|
|
|
|
/// </summary>
|
2020-11-07 11:40:58 -05:00
|
|
|
|
public static TimeSpan SocketTimeout(int retryAttempt)
|
|
|
|
|
{
|
|
|
|
|
return retryAttempt switch
|
|
|
|
|
{
|
|
|
|
|
1 => TimeSpan.FromMilliseconds(550),
|
|
|
|
|
2 => TimeSpan.FromMilliseconds(1000),
|
|
|
|
|
3 => TimeSpan.FromMilliseconds(2000),
|
2020-11-11 18:31:26 -05:00
|
|
|
|
4 => TimeSpan.FromMilliseconds(5000),
|
2022-01-26 11:32:16 -05:00
|
|
|
|
_ => TimeSpan.FromMilliseconds(10000)
|
2020-11-07 11:40:58 -05:00
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-02 01:25:06 -04:00
|
|
|
|
}
|
2022-03-23 12:38:09 -04:00
|
|
|
|
}
|