Table of Contents

Class Source

Namespace
OpenGSQ.Protocols
Assembly
OpenGSQ.dll

Source Engine Query Protocol

public class Source : ProtocolBase
Inheritance
Source
Derived
Inherited Members

Constructors

Source(string, int, int)

Initializes a new instance of the Source class.

public Source(string host, int port = 27015, int timeout = 5000)

Parameters

host string

The host to connect to.

port int

The port to connect to. Default is 27015.

timeout int

The connection timeout in milliseconds. Default is 5 seconds.

Fields

A2S_INFO

The byte array representing the A2S_INFO request.

protected byte[] A2S_INFO

Field Value

byte[]

A2S_PLAYER

The byte array representing the A2S_PLAYER request.

protected byte[] A2S_PLAYER

Field Value

byte[]

A2S_RULES

The byte array representing the A2S_RULES request.

protected byte[] A2S_RULES

Field Value

byte[]

Properties

FullName

Gets the full name of the protocol.

public override string FullName { get; }

Property Value

string

Methods

GetInfo()

Retrieves information about the server including, but not limited to: its name, the map currently being played, and the number of players.
See: https://developer.valvesoftware.com/wiki/Server_queries#A2S_INFO

public Task<PartialInfo> GetInfo()

Returns

Task<PartialInfo>

A task that represents the asynchronous operation. The task result contains the server information.

Exceptions

InvalidPacketException

Thrown when the received packet type is not S2A_INFO_SRC or S2A_INFO_DETAILED.

TimeoutException

Thrown when the operation times out.

GetPlayers()

This query retrieves information about the players currently on the server.
See: https://developer.valvesoftware.com/wiki/Server_queries#A2S_PLAYER

public Task<List<Player>> GetPlayers()

Returns

Task<List<Player>>

A task that represents the asynchronous operation. The task result contains a list of players.

Exceptions

InvalidPacketException

Thrown when the received packet type is not S2A_PLAYER.

TimeoutException

Thrown when the operation times out.

GetRules()

Returns the server rules, or configuration variables in name/value pairs.
See: https://developer.valvesoftware.com/wiki/Server_queries#A2S_RULES

public Task<Dictionary<string, string>> GetRules()

Returns

Task<Dictionary<string, string>>

A task that represents the asynchronous operation. The task result contains a dictionary of rules where the rule name is the key and the rule value is the value.

Exceptions

InvalidPacketException

Thrown when the received packet type is not S2A_RULES.

TimeoutException

Thrown when the operation times out.