o3de / sig-network

9 stars 8 forks source link

RFC: Amazon GameLift FlexMatch Integration #9

Closed onecent1101 closed 2 years ago

onecent1101 commented 3 years ago

Summary

FlexMatch is a Amazon GameLift matchmaking service which allows multiplayer game developers to customize and build multiplayer matchmaking experiences to best fit their games. It gives flexibility to customize key aspects of the matchmaking process, including fine-tuning the matching algorithm. This RFC covers integrating Amazon GameLift FlexMatch into the AWS GameLift Gem.

What is the relevance of this feature?

Integrate AWS GameLift Gem with FlexMatch feature to support multiplayer game matchmaking so that players can be easily grouped with other compatible players for each game match.

Personas

O3DE multiplayer game developer who wants to build matchmaking experience to evaluate and select compatible player for each match of their game.

User Stories

In Scope

Out of Scope

Feature design description

This design proposes integrating FlexMatch matchmaking support into the existing AWS GameLift Gem such that developers of multiplayer games can easily build, experiment and deploy matchmaking features to group players and place them in game sessions. The O3DE AWS GameLift gem will support the FlexMatch workflows outlined here and in the workflow section.

FlexMatch also supports two backfilling games so games can start with fewer players to accelerate matchmaking and new players can be added to the game in cases such as players failing to join.

The AWS GameLift Gem will support two backfill modes: manual and automatic. In manual mode, the developer’s service code can make the decision if and when to backfill; no backfill will occur unless the server explicitly starts a backfill request. In automatic mode, the GameLift server SDK will automatically start backfill requests if the sessions starts without a full complement of players. Note: backfill mode is managed in the GameLift matchmaking configuration.

Requirements & Goals

Terminology

Workflow

Matchmaking
  1. Request matchmaking for player against Amazon GameLift FlexMatch by calling StartMatchmaking.

    • Amazon GameLift service will generate matchmaking ticket and put in ticket pool. Ticket will remain in pool until it is matched or time limit is reached.
    • Amazon GameLift service will evaluate ticket based on ticket age and build match based on matchmaking configuration.
  2. Track matchmaking ticket by using client local ticket tracker.

    • [Player Acceptance Enabled] Player needs to AcceptMatch to fulfill match ticket - if any player in proposed match rejects, ticket will go to FAILURE and won't be processed; for players accept, their ticket will go back to pool.
    • When acceptable match is found, Amazon GameLift service will create new game session automatically.
  3. Once game session is created, local ticket tracker will get updated ticket with game session connection data, like ip address and created player session id for player.

  4. Connect player to the match.

Note: Player can cancel match at any time by calling StopMatchmaking. If there is ongoing local ticket tracker process, it should be stopped as well.

Backfill matchmaking

The workflow is mostly the same with standard matchmaking workflow, except step 2 as game session is existed when acceptable match is found:

Note: For manual backfill, developer has responsibility to send backfill request on server side by calling StartMatchBackfill whenever a matched game has one or more open player slots, like a match game starts with open player slots, or player leaves an ongoing match game. Note: Depending on the game style, developer might want to stop backfill after reaching specific conditions, like game has 5mins left, etc. Then server can stop backfill by calling StopMatchBackfill.

Technical design description

Client APIs

Update ISessionRequests.h by adding client public API requests.

struct AcceptMatchRequest
{
    bool m_acceptMatch;
    AZStd::vector<AZStd::string> m_playerIds;
    AZStd::string m_ticketId;
};

struct StartMatchmakingRequest
{
    AZStd::string m_ticketId;
};

struct StopMatchmakingRequest
{
    AZStd::string m_ticketId;
};

Update ISessionRequests for AcceptMatch, StartMatchmaking and StopMatchmaking

virtual void AcceptMatch(const AcceptMatchRequest& request) = 0;

virtual AZStd::string StartMatchmaking(const StartMatchmakingRequest& request) = 0;

virtual void StopMatchmaking(const StopMatchmakingRequest& request) = 0;

Update ISessionAsyncRequests and SessionAsyncRequestNotifications for AcceptMatch, StartMatchmaking and StopMatchmaking

virtual void AcceptMatchAsync(const AcceptMatchRequest& request) = 0;
virtual void OnAcceptMatchAsyncComplete() = 0;

virtual void StartMatchmakingAsync(const StartMatchmakingRequest& request) = 0;
virtual void OnStartMatchmakingAsyncComplete(const AZStd::string& matchmakingTicketId) = 0;

virtual void StopMatchmakingAsync(const StopMatchmakingRequest& request) = 0;
virtual void OnStopMatchmakingAsyncComplete() = 0;

Add AWS GameLift Gem matchmaking requests AWSGameLiftAcceptMatchRequest, AWSGameLiftStartMatchmakingRequest and AWSGameLiftStopMatchmakingRequest under Gems/AWSGameLift/Code/AWSGameLiftClient/Include/Request as Amazon GameLift service requires extra attributes for matchmaking request 6

Server Notifications

Update SessionNotifications with OnUpdateSessionBegin

virtual void OnUpdateSessionBegin(const SessionConfig& sessionConfig) = 0;

Server APIs

Update IAWSGameLiftServerRequests with backfill server APIs

class IAWSGameLiftServerRequests
{
public:
    virtual void StartMatchBackfill(const StartMatchBackfillRequest& request) = 0;
    virtual void StopMatchBackfill(const StopMatchBackfillRequest& request) = 0;
};

Components

AWSGameLiftClientLocalTicketTracker Instead of having a backend client service to track FlexMatch event notification, AWS GameLift Gem will have a client local ticker manager consistently polls and describes matchmaking ticket.

AWSGameLiftClientLocalTicketTracker should be flexible to replace by implementing internal interface IAWSGameLiftMatchmakingTicketRequests

class IAWSGameLiftMatchmakingTicketRequests
{
public:
    virtual void StartPolling(const AZStd::string& ticketId, const AZStd::string& playerId) = 0;
    virtual void StopPolling() = 0;
};

What are the advantages of the feature?

What are the disadvantages of the feature?

How will this be implemented or integrated into the O3DE environment?

Are there any alternatives to this feature?

Yes, customer are free to implement their own multiplayer matchmaking mechanism without using Amazon GameLift FlexMatch. Customers can also use GameLift without FlexMatch features.

How will users learn this feature?

Are there any open questions?

Q: Should the feature provide client service solution to track matchmaking event notification (including CDK application sample to setup required resources)?

Context: As suggested by Amazon GameLift service, all games in public release should use notifications regardless of volume. The continuous polling approach is only appropriate for games in development with low matchmaking usage, because large volume DescribeMatchmaking calls in short period time can easily get your requests throttled which will delay client to get latest match status.

Solution: Setup event notifications through Amazon Cloudwatch events or Amazon SNS topics. See details in https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-notification.html

Cost: The feature need to add Amazon Cloudwatch events or Amazon SNS topics setup in CDK application sample, and cost will depend on corresponding service usage price.

lmbr-pip commented 2 years ago

RFC accepted by SIG Oct 26th 2021.

Issue to be closed once archived.