Table of Contents

Class Unreal2

Namespace
OpenGSQ.Protocols
Assembly
OpenGSQ.dll

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

host string
port int
timeout int

Fields

DETAILS

Represents the byte value for details.

protected const byte DETAILS = 0

Field Value

byte

PLAYERS

Represents the byte value for players.

protected const byte PLAYERS = 2

Field Value

byte

RULES

Represents the byte value for rules.

protected const byte RULES = 1

Field Value

byte

Properties

FullName

Gets the full name of the protocol.

public override string FullName { get; }

Property Value

string

Methods

GetDetails(bool)

Asynchronously retrieves the details of the server.

public Task<Status> GetDetails(bool stripColor = true)

Parameters

stripColor bool

A 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 bool

A boolean value indicating whether to strip color codes. Default is true.

Returns

Task<List<Player>>

A list of players of the server.

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 bool

A boolean value indicating whether to strip color codes. Default is true.

Returns

Task<Rules>

The rules of the server.

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 BinaryReader

The BinaryReader to read the string from.

stripColor bool

Optional 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 BinaryReader

The binary reader to read the string from.

stripColor bool

Optional 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 string

The input text which may contain color codes.

Returns

string

A string with color codes stripped out.