Class GameyeMatchAllocator

Namespace
Unity.Multiplayer.Core

IMatchAllocator for Gameye: starts one session per match from an image already registered with Gameye, waits for it to report ready 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 GameyeMatchAllocator : IMatchAllocator
Inheritance
GameyeMatchAllocator
Implements
Inherited Members

Constructors

GameyeMatchAllocator(IGameyeApiClient, IJoinCodeService, string, string, IReadOnlyList<GameyePortSpec>, IReadOnlyDictionary<string, string>, string)

Starts sessions of image imageName in location through api, publishing join codes through joinCodes. Every session declares the same ports and environmentVariables (rendezvous URL/secret and the like); gamePortName is the Name the game port is declared under.

public GameyeMatchAllocator(IGameyeApiClient api, IJoinCodeService joinCodes, string imageName, string location, IReadOnlyList<GameyePortSpec> ports, IReadOnlyDictionary<string, string> environmentVariables = null, string gamePortName = "game")

Parameters

api IGameyeApiClient
joinCodes IJoinCodeService
imageName string
location string
ports IReadOnlyList<GameyePortSpec>
environmentVariables IReadOnlyDictionary<string, string>
gamePortName string

Exceptions

ArgumentNullException

api, joinCodes or ports is null.

ArgumentException

imageName, location or gamePortName is empty, or ports is empty.

Properties

DisplayName

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

public string DisplayName { get; }

Property Value

string

GamePortName

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

public string GamePortName { get; }

Property Value

string

ImageName

The image name AllocateAsync(MatchRequest, CancellationToken) starts sessions from.

public string ImageName { get; }

Property Value

string

Location

The Gameye location/fleet sessions start in.

public string Location { 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 Gameye to report the session ready before giving up. Default 2 minutes.

public TimeSpan Timeout { get; set; }

Property Value

TimeSpan

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.

RegisterImageAsync(string, string, string, CancellationToken)

Registers (or updates) ImageName with Gameye, 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.

public Task RegisterImageAsync(string imageReference, string registryUsername = null, string registryPassword = null, CancellationToken cancellationToken = default)

Parameters

imageReference string
registryUsername string
registryPassword string
cancellationToken CancellationToken

Returns

Task

Exceptions

ArgumentException

imageReference is empty.

MatchAllocationException

Gameye 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).