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

api IEdgegapApiClient
joinCodes IJoinCodeService
appName string
versionName string
gamePortName string

Exceptions

ArgumentNullException

api or joinCodes is null.

ArgumentException

appName, versionName or gamePortName is empty.

Properties

AppName

The Edgegap application name.

public string AppName { get; }

Property Value

string

DisplayName

A name for people and for logs ("Edgegap", "Gameye", ...).

public string DisplayName { get; }

Property Value

string

GamePortName

The port name a deployment's game port is registered under.

public string GamePortName { get; }

Property Value

string

PollInterval

How often AllocateAsync(MatchRequest, CancellationToken) polls while waiting. Default 2 seconds.

public TimeSpan PollInterval { get; set; }

Property Value

TimeSpan

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

TimeSpan

VersionName

public string VersionName { get; }

Property Value

string

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

request MatchRequest
cancellationToken CancellationToken

Returns

Task<MatchAllocation>

Exceptions

ArgumentNullException

request is 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

imageReference string
ports IReadOnlyList<EdgegapPortSpec>
environmentVariables IReadOnlyDictionary<string, string>
cancellationToken CancellationToken

Returns

Task

Exceptions

ArgumentException

imageReference is empty, or ports is 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

allocation MatchAllocation
cancellationToken CancellationToken

Returns

Task

Exceptions

ArgumentNullException

allocation is null.

MatchAllocationException

The provider could not be reached (a refusal because the allocation is already gone is swallowed, not thrown).