Class Unreal2
Unreal 2 Protocol
public class Unreal2 : ProtocolBase
- Inheritance
-
Unreal2
- Derived
- Inherited Members
Constructors
Unreal2(string, int, int)
Initializes a new instance of the Unreal2 class.
public Unreal2(string host, int port, int timeout = 5000)
Parameters
Fields
DETAILS
Represents the byte value for details.
protected const byte DETAILS = 0
Field Value
PLAYERS
Represents the byte value for players.
protected const byte PLAYERS = 2
Field Value
RULES
Represents the byte value for rules.
protected const byte RULES = 1
Field Value
Properties
FullName
Gets the full name of the protocol.
public override string FullName { get; }
Property Value
Methods
GetDetails(bool)
Asynchronously retrieves the details of the server.
public Task<Status> GetDetails(bool stripColor = true)
Parameters
stripColor
boolA boolean value indicating whether to strip color codes from the server name. Default is true.
Returns
- Task<Status>
A Task<TResult> representing the server status, including details such as server ID, IP, ports, server name, map name, game type, player count, max players, ping, flags, and skill level.
Exceptions
- InvalidPacketException
Thrown when the packet header does not match the expected DETAILS header.
- TimeoutException
Thrown when the operation times out.
GetPlayers(bool)
Gets the players of the server.
public Task<List<Player>> GetPlayers(bool stripColor = true)
Parameters
stripColor
boolA boolean value indicating whether to strip color codes. Default is true.
Returns
Exceptions
- InvalidPacketException
Thrown when the packet header does not match the expected value.
- TimeoutException
Thrown when the operation times out.
GetRules(bool)
Gets the rules of the server.
public Task<Rules> GetRules(bool stripColor = true)
Parameters
stripColor
boolA boolean value indicating whether to strip color codes. Default is true.
Returns
Exceptions
- InvalidPacketException
Thrown when the packet header does not match the expected value.
- TimeoutException
Thrown when the operation times out.
ReadNullString(BinaryReader, bool)
Reads a string from a binary stream, optionally stripping color information.
protected string ReadNullString(BinaryReader br, bool stripColor = false)
Parameters
br
BinaryReaderThe BinaryReader to read the string from.
stripColor
boolOptional parameter. If true, color information is stripped from the string.
Returns
- string
The string read from the binary stream, with color information stripped if stripColor is true.
ReadUnreal2String(BinaryReader, bool)
Reads a string from a binary reader.
protected string ReadUnreal2String(BinaryReader br, bool stripColor)
Parameters
br
BinaryReaderThe binary reader to read the string from.
stripColor
boolOptional parameter. If set to true, color information will be stripped from the string. Default is false.
Returns
- string
The string read from the binary reader. If 'stripColor' is true, the returned string will have color information stripped.
StripColor(string)
Strips color codes from the input text.
public static string StripColor(string text)
Parameters
text
stringThe input text which may contain color codes.
Returns
- string
A string with color codes stripped out.