Class GameLiftMatchAllocator
- Namespace
- Unity.Multiplayer.Core
IMatchAllocator for AWS GameLift: starts a game session on a fleet mp-host already created (build upload + fleet create -- see docs/articles/hosting/gamelift.md), waits for GameLift to report it ACTIVE with its connection info, and publishes the result through an IJoinCodeService so a player gets a short code instead of a raw address.
public sealed class GameLiftMatchAllocator : IMatchAllocator
- Inheritance
-
GameLiftMatchAllocator
- Implements
- Inherited Members
Remarks
Unlike Edgegap/Gameye, GameLift also needs a reservation per player before they connect:
CreatePlayerSessionAsync(MatchAllocation, string, string, CancellationToken) returns a player session id the matchmaker must hand
that player to send as their PlayerToken (RFC 0001's existing
reconnect-token field, reused rather than adding a new wire field). The server's
GameLiftServerHost (unity/.../Runtime/Hosting/GameLift, compiled in only under
the MINDATTIC_GAMELIFT version define) reads that token back off the connected client's
seat and calls the GameLift Server SDK's AcceptPlayerSession/RemovePlayerSession.
ReleaseAsync(MatchAllocation, CancellationToken) only revokes the join code: GameLift has no API to force a
game session to end from the outside -- only the server process itself, by calling
ProcessEnding (again, GameLiftServerHost), actually ends one. A matchmaker that
wants a match to stop should tell the game to wrap up (its own RPC or admin command), not
expect ReleaseAsync(MatchAllocation, CancellationToken) to kill the process.
Constructors
GameLiftMatchAllocator(IGameLiftApiClient, IJoinCodeService, string, string)
Starts game sessions on fleet fleetId (or, when aliasId
is given, through that alias instead -- so mp-host can swap fleets on an update without this
allocator changing) through api, publishing join codes through
joinCodes.
public GameLiftMatchAllocator(IGameLiftApiClient api, IJoinCodeService joinCodes, string fleetId, string aliasId = null)
Parameters
apiIGameLiftApiClientjoinCodesIJoinCodeServicefleetIdstringaliasIdstring
Exceptions
- ArgumentNullException
apiorjoinCodesis null.- ArgumentException
fleetIdis empty.
Properties
AliasId
The alias AllocateAsync(MatchRequest, CancellationToken) resolves instead of FleetId, or null.
public string AliasId { get; }
Property Value
DisplayName
A name for people and for logs ("Edgegap", "Gameye", ...).
public string DisplayName { get; }
Property Value
FleetId
The fleet AllocateAsync(MatchRequest, CancellationToken) starts sessions on.
public string FleetId { 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 GameLift to report the session ACTIVE before giving up. Default 2 minutes.
public TimeSpan Timeout { get; set; }
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.
CreatePlayerSessionAsync(MatchAllocation, string, string, CancellationToken)
Reserves a seat on allocation's game session for playerId.
The matchmaker must hand the returned player session id to that player to send as their
PlayerToken before they connect; the server's
GameLiftServerHost reads it back off the connected client's seat to call
AcceptPlayerSession.
public Task<string> CreatePlayerSessionAsync(MatchAllocation allocation, string playerId, string playerData = null, CancellationToken cancellationToken = default)
Parameters
allocationMatchAllocationplayerIdstringplayerDatastringcancellationTokenCancellationToken
Returns
Exceptions
- ArgumentNullException
allocationis null.- ArgumentException
playerIdis empty.- MatchAllocationException
GameLift 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).