OpenGSQ 1.3.0

.NET Standard 2.0
dotnet add package OpenGSQ --version 1.3.0
NuGet\Install-Package OpenGSQ -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenGSQ" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenGSQ --version 1.3.0
#r "nuget: OpenGSQ, 1.3.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install OpenGSQ as a Cake Addin
#addin nuget:?package=OpenGSQ&version=1.3.0

// Install OpenGSQ as a Cake Tool
#tool nuget:?package=OpenGSQ&version=1.3.0

OpenGSQ .NET Library

The OpenGSQ .NET library provides a convenient way to query servers from applications written in the C# language.

Installation

Find the package through NuGet Package Manager or install it with following command.

dotnet add package OpenGSQ

Usage

Source Query Protocol

using System;
using OpenGSQ.Protocols;

namespace OpenGSQExample
{
    class Program
    {
        static void Main(string[] args)
        {
            Source source = new Source("91.216.250.14", 27015);

            // Get Server Info
            Source.IResponse response = source.GetInfo();
           
            Console.WriteLine(response.Name); // skial.com | SAXTON HALE | US ███
            Console.WriteLine(response.Map);  // vsh_dust_showdown_deluxe_r1

            // If you want to get full response, try cast to SourceResponse or GoldSourceResponse
            if (response is Source.SourceResponse sourceResponse)
            {
                // Casted from IResponse to SourceResponse

                Console.WriteLine(sourceResponse.ID); // 440
            }
            else if (response is Source.GoldSourceResponse goldSourceResponse)
            {
                // Casted from IResponse to GoldSourceResponse

                Console.WriteLine(goldSourceResponse.Address);
            }
        }
    }
}

Source RCON Protocol

using System;
using OpenGSQ.Protocols;

namespace OpenGSQExample
{
    class Program
    {
        static void Main(string[] args)
        {
            using var remoteConsole = new Source.RemoteConsole("", 27015);

            try
            {
                // Authenticate with rcon password
                remoteConsole.Authenticate("");

                // Send command and receive the response
                string response = remoteConsole.SendCommand("cvarlist");

                Console.WriteLine(response);
            }
            catch (Exception e)
            {
                Console.WriteLine($"{e.Message}");
            }
        }
    }
}

Supported Protocols

var gameSpy1 = new GameSpy1("123.123.123.123", 7778);
var gameSpy2 = new GameSpy2("123.123.123.123", 23000);
var gameSpy3 = new GameSpy3("123.123.123.123", 29900);
var gameSpy4 = new GameSpy4("123.123.123.123", 19132);
var quake1 = new Quake1("123.123.123.123", 27500);
var quake2 = new Quake2("123.123.123.123", 27910);
var quake3 = new Quake3("123.123.123.123", 27960);
var source = new Source("123.123.123.123", 27015); // Both Source and Goldsource supported

See OpenGSQTests/Protocols for the tests.

See OpenGSQTests/Results for tests outputs.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 245 1/13/2022
1.2.0 236 10/31/2021
1.1.1 219 7/4/2021
1.0.1 177 6/4/2021