Class EdgegapMatchAllocator
- Namespace
- Unity.Multiplayer.Core
IMatchAllocator for Edgegap: deploys one container per match from an app version already pointed at the pushed GHCR image, waits for Edgegap to report it running with its ports mapped, and publishes the result through an IJoinCodeService so a player gets a short code instead of a raw address.
public sealed class EdgegapMatchAllocator : IMatchAllocator
- Inheritance
-
EdgegapMatchAllocator
- Implements
- Inherited Members
Constructors
EdgegapMatchAllocator(IEdgegapApiClient, IJoinCodeService, string, string, string)
Deploys versionName of Edgegap app appName
through api, publishing join codes through joinCodes.
gamePortName is the Name the game port was
declared under when the app version was created (see EnsureAppVersionAsync(string, IReadOnlyList<EdgegapPortSpec>, IReadOnlyDictionary<string, string>, CancellationToken)).
public EdgegapMatchAllocator(IEdgegapApiClient api, IJoinCodeService joinCodes, string appName, string versionName, string gamePortName = "game")
Parameters
apiIEdgegapApiClientjoinCodesIJoinCodeServiceappNamestringversionNamestringgamePortNamestring
Exceptions
- ArgumentNullException
apiorjoinCodesis null.- ArgumentException
appName,versionNameorgamePortNameis empty.
Properties
AppName
The Edgegap application name.
public string AppName { get; }
Property Value
DisplayName
A name for people and for logs ("Edgegap", "Gameye", ...).
public string DisplayName { get; }
Property Value
GamePortName
The port name a deployment's game port is registered under.
public string GamePortName { get; }
Property Value
PollInterval
How often AllocateAsync(MatchRequest, CancellationToken) polls while waiting. Default 2 seconds.
public TimeSpan PollInterval { get; set; }
Property Value
Timeout
How long AllocateAsync(MatchRequest, CancellationToken) waits for Edgegap to report the deployment running before giving up. Default 2 minutes.
public TimeSpan Timeout { get; set; }
Property Value
VersionName
The app version AllocateAsync(MatchRequest, CancellationToken) deploys.
public string VersionName { get; }
Property Value
Methods
AllocateAsync(MatchRequest, CancellationToken)
Requests a server for request and waits until it can be joined.
public Task<MatchAllocation> AllocateAsync(MatchRequest request, CancellationToken cancellationToken = default)
Parameters
requestMatchRequestcancellationTokenCancellationToken
Returns
Exceptions
- ArgumentNullException
requestis null.- MatchAllocationException
The provider refused the request, could not be reached, or never came up in time.
EnsureAppVersionAsync(string, IReadOnlyList<EdgegapPortSpec>, IReadOnlyDictionary<string, string>, CancellationToken)
Creates or updates the app version this allocator deploys, pointing it at
imageReference (the same GHCR reference mp-host just pushed). Call this
once per build, before the first match of that build is allocated; it is safe to call again
for the same version with a newer image.
public Task EnsureAppVersionAsync(string imageReference, IReadOnlyList<EdgegapPortSpec> ports, IReadOnlyDictionary<string, string> environmentVariables = null, CancellationToken cancellationToken = default)
Parameters
imageReferencestringportsIReadOnlyList<EdgegapPortSpec>environmentVariablesIReadOnlyDictionary<string, string>cancellationTokenCancellationToken
Returns
Exceptions
- ArgumentException
imageReferenceis empty, orportsis empty.- MatchAllocationException
Edgegap refused the request or could not be reached.
ReleaseAsync(MatchAllocation, CancellationToken)
Tears down a server AllocateAsync(MatchRequest, CancellationToken) returned, once the match is over.
public Task ReleaseAsync(MatchAllocation allocation, CancellationToken cancellationToken = default)
Parameters
allocationMatchAllocationcancellationTokenCancellationToken
Returns
Exceptions
- ArgumentNullException
allocationis null.- MatchAllocationException
The provider could not be reached (a refusal because the allocation is already gone is swallowed, not thrown).