ManiaAPI.Xml.Extensions.Hosting
2.9.0
dotnet add package ManiaAPI.Xml.Extensions.Hosting --version 2.9.0
NuGet\Install-Package ManiaAPI.Xml.Extensions.Hosting -Version 2.9.0
<PackageReference Include="ManiaAPI.Xml.Extensions.Hosting" Version="2.9.0" />
<PackageVersion Include="ManiaAPI.Xml.Extensions.Hosting" Version="2.9.0" />
<PackageReference Include="ManiaAPI.Xml.Extensions.Hosting" />
paket add ManiaAPI.Xml.Extensions.Hosting --version 2.9.0
#r "nuget: ManiaAPI.Xml.Extensions.Hosting, 2.9.0"
#:package ManiaAPI.Xml.Extensions.Hosting@2.9.0
#addin nuget:?package=ManiaAPI.Xml.Extensions.Hosting&version=2.9.0
#tool nuget:?package=ManiaAPI.Xml.Extensions.Hosting&version=2.9.0
ManiaAPI.Xml.Extensions.Hosting
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
using ManiaAPI.Xml.Extensions.Hosting;
builder.Services.AddMasterServerMP4();
You can now inject MasterServerMP4, as long as you're fine relying on Maniaplanet relay 1 to continue running, and use it without additional steps. Compression is enabled.
If you want to have better control over the selection of master servers, use this setup:
using ManiaAPI.Xml.Extensions.Hosting;
builder.Services.AddMasterServerMP4();
// --------------------
// Do the setup
var factory = provider.GetRequiredService<IMasterServerMP4Factory>();
// RequestWaitingParamsAsync should run at the start of your application, and when you need to refresh the master servers
var waitingParams = await factory.RequestWaitingParamsAsync();
// For example selects the first available master server (more overloads are available)
var masterServer = factory.CreateClient();
Features this setup brings:
- You can inject
IMasterServerMP4Factoryto create multiple instances ofMasterServerMP4with different master servers and refresh them - You can inject
MasterServerMP4to get a default instance usingManiaplanet relay 1 - You can inject
InitServerMP4to get the init server - All
MasterServerMP4handle GZIP compression
The same idea works for ManiaPlanet 3 with AddMasterServerMP3(), which uses Maniaplanet relay 5 by default.
Setup for TMT
using ManiaAPI.Xml.Extensions.Hosting;
// Register the services
builder.Services.AddMasterServerTMT();
// --------------------
// Do the setup
var factory = provider.GetRequiredService<IMasterServerTMTFactory>();
// RequestWaitingParamsAsync should run at the start of your application, and when you need to refresh the master servers
await factory.RequestWaitingParamsAsync();
// For example selects the PC master server
var masterServerPC = factory.CreateClient(Platform.PC);
Features this last setup brings:
- You can inject
AggregatedMasterServerTMTto conveniently work with all master servers - You can inject
IMasterServerTMTFactoryto create multiple instances ofMasterServerTMTwith different 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
InitServerTMTandMasterServerTMTcan be injected using[FromKeyedServices(Platform.PC)] - All
MasterServerTMThandle GZIP compression
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(...)].
Resilience
HTTP requests can transiently fail, so it's a good idea to add some retry logic.
AddMasterServerTMUF returns an IHttpClientBuilder directly, while AddMasterServerMP4, AddMasterServerMP3, and AddMasterServerTMT expose configureInitServer and configureMasterServer callbacks, so you can add Microsoft.Extensions.Http.Resilience to automatically retry requests, apply timeouts, and use circuit breakers:
using ManiaAPI.Xml.Extensions.Hosting;
builder.Services.AddMasterServerTMUF()
.AddStandardResilienceHandler();
builder.Services.AddMasterServerMP4(
configureInitServer: http => http.AddStandardResilienceHandler(),
configureMasterServer: http => http.AddStandardResilienceHandler());
builder.Services.AddMasterServerTMT(
configureInitServer: http => http.AddStandardResilienceHandler(),
configureMasterServer: http => http.AddStandardResilienceHandler());
| Product | Versions 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. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- ManiaAPI.Xml (>= 2.9.0)
-
net8.0
- ManiaAPI.Xml (>= 2.9.0)
-
net9.0
- ManiaAPI.Xml (>= 2.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.