ManiaAPI.Xml.Extensions.Hosting 2.2.0

dotnet add package ManiaAPI.Xml.Extensions.Hosting --version 2.2.0
                    
NuGet\Install-Package ManiaAPI.Xml.Extensions.Hosting -Version 2.2.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="ManiaAPI.Xml.Extensions.Hosting" Version="2.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ManiaAPI.Xml.Extensions.Hosting" Version="2.2.0" />
                    
Directory.Packages.props
<PackageReference Include="ManiaAPI.Xml.Extensions.Hosting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ManiaAPI.Xml.Extensions.Hosting --version 2.2.0
                    
#r "nuget: ManiaAPI.Xml.Extensions.Hosting, 2.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ManiaAPI.Xml.Extensions.Hosting&version=2.2.0
                    
Install ManiaAPI.Xml.Extensions.Hosting as a Cake Addin
#tool nuget:?package=ManiaAPI.Xml.Extensions.Hosting&version=2.2.0
                    
Install ManiaAPI.Xml.Extensions.Hosting as a Cake Tool

ManiaAPI.Xml.Extensions.Hosting

NuGet

Provides an efficient way to inject all XML services into your application.

Setup for TMUF

using ManiaAPI.Xml.Extensions.Hosting;

builder.Services.AddMasterServerTMUF();

Setup for ManiaPlanet

Relying on Maniaplanet relay 2 to continue running:

using ManiaAPI.Xml.Extensions.Hosting;

builder.Services.AddMasterServerMP4();

You can now inject MasterServerMP4 (registered as singleton) and use it without additional steps. Compression is enabled.

If you want to be extra sure the correct master server is selected, use this setup:

using ManiaAPI.Xml.Extensions.Hosting;

builder.Services.AddInitServerMP4();
builder.Services.AddMasterServerMP4();

// In a scope, retrieve init server, and use it for validating the master server
// No need for CreateScopeAsync if your service is scoped
await using var scope = provider.CreateScopeAsync();

var initServer = scope.ServiceProvider.GetRequiredService<InitServerMP4>();
var masterServer = scope.ServiceProvider.GetRequiredService<MasterServerMP4>();

await initServer.ValidateAsync(masterServer);

Setup for TMT

using ManiaAPI.Xml.Extensions.Hosting;

// Register the services
builder.Services.AddMasterServerTMT();

// Do the setup
// This should run at the start of your application, or when you need to refresh the master servers
// No need for CreateScopeAsync if your service is scoped
await using var scope = provider.CreateScopeAsync();

foreach (var platform in Enum.GetValues<Platform>())
{
    var initServer = scope.ServiceProvider.GetRequiredKeyedService<InitServerTMT>(platform);
    var waitingParams = await initServer.GetWaitingParamsAsync(cancellationToken);
    var masterServer = scope.ServiceProvider.GetRequiredKeyedService<MasterServerTMT>(platform);
    masterServer.Client.BaseAddress = waitingParams.MasterServers.First().GetUri();
}

Features this last setup brings:

  • You can inject AggregatedMasterServerTMT to conveniently work with all master servers
  • You can inject ImmutableDictionary<Platform, MasterServerTMT> to get all master servers as individual instances
  • If you don't need specific platform context, you can inject IEnumerable<MasterServerTMT> to get all master servers
  • Specific InitServerTMT and MasterServerTMT can be injected using [FromKeyedServices(Platform.PC)]
  • All MasterServerTMT handle compression

[!WARNING] If you just inject MasterServerTMT alone, it will give the last-registered one (in this case, PS4). If you need a specific platform, use [FromKeyedServices(...)].

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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
2.2.0 175 11 days ago