Adawolfa.ETWSL

.NET Enemy Territory master and server query library.


Keywords
dotnet-library, enemy-territory
Install
Install-Package Adawolfa.ETWSL -Version 1.1.1

Documentation

Adawolfa.ETWSL

This simple library provides easy ET server status and master server list retrieval for .NET.

Installation

dotnet add package Adawolfa.ETWSL

Getting serverlist

Use MasterQuery for obtaining the server list. You have to pass list of master servers and optionally, you can set the timeout.

var masterQuery = new MasterQuery(new EndPoint[]
{
	new DnsEndPoint("etmaster.idsoftware.com", 27950),
	new DnsEndPoint("master0.etmaster.net", 27950),
}) {
	Timeout = 10,
};

IEnumerable<IPEndPoint> servers = await masterQuery.Query();

Getting serverstatus

var serverQuery = new ServerQuery() {
	Timeout = 5,
};

ServerQuery.Server server = await serverQuery.Query(ipEndPoint);

Method will return NULL when the server is not responding. See sample application for detailed API.

Colors

Server hostname and player name is returned as a Color.ColoredText. You can parse any string using Color.Parse() method.

You can print colored string like this (but note that there is only limited number of colors in CLI):

Color.Console.WriteLine(coloredText);

You can, of course, manually format the output string:

foreach (var part in coloredText.Text) {
	html += @"<span style=""color: #" + part.Item1.Hex + """>" + part.Item2 + "</span>";
	// Or use part.Item1.Color (System.Drawing.Color).
}

You might want to get a string with no color codes:

foreach (var player in server.Players) {
	Console.WriteLine(player.Name.Clean);
}

See tests for usage.

Licence

Seriously, Do What The Fuck You Want To.