Skip to main content

Introduction to matchmaking customization

Last updated on November 1, 2024

Overview

This article guides you through modifying the Extend Override app template for the matchmaking function, helping you transform it into a customized app that meets your specific needs.

Contract functions

The following are the functions in the contract:

service MatchFunction {
rpc GetStatCodes(GetStatCodesRequest) returns (StatCodesResponse);
rpc EnrichTicket(EnrichTicketRequest) returns (EnrichTicketResponse);
rpc ValidateTicket(ValidateTicketRequest) returns (ValidateTicketResponse);
rpc BackfillMatches(stream BackfillMakeMatchesRequest) returns (stream BackfillResponse);
rpc MakeMatches(stream MakeMatchesRequest) returns (stream MatchResponse);
}

GetStatCodes

The flow begins with a call to GetStatCode, which retrieves relevant statistical codes from AGS Storage Statistics. These codes are essential for gathering player-specific stats to inform matchmaking decisions. For example, retrieving stat codes for "mmr" enables AGS Matchmaking to gather player statistics based on those specified codes.

In the app template, the following function can be found in src/master/src/AccelByte.PluginArch.Demo.Server/Services/MatchFunctionService.cs.

public override Task<StatCodesResponse> GetStatCodes(GetStatCodesRequest request, ServerCallContext context)
{
...
}

EnrichTicket

Next, EnrichTicket is called to add additional attributes or logic to the match ticket. This customization step allows you to tailor tickets with specific attributes that will be used in later stages.

In the app template, the following function can be found in src/master/src/AccelByte.PluginArch.Demo.Server/Services/MatchFunctionService.cs.

public override Task<EnrichTicketResponse> EnrichTicket(EnrichTicketRequest request, ServerCallContext context)
{
...
}

ValidateTicket

The ValidateTicket function then validates each match ticket according to a defined ruleset. This step ensures that only tickets meeting the criteria progress to matchmaking, returning a boolean to indicate validity.

In the app template, the following function can be found in src/master/src/AccelByte.PluginArch.Demo.Server/Services/MatchFunctionService.cs.

public override Task<ValidateTicketResponse> ValidateTicket(ValidateTicketRequest request, ServerCallContext context)
{
...
}

BackfillMatches

BackfillMatches – After validation, the system initiates the BackfillMatches function to allocate matchTickets into existing game sessions as needed. This step aims to optimize session capacity and resource use according to the game session criteria.

In the app template, the following function can be found in src/master/src/AccelByte.PluginArch.Demo.Server/Services/MatchFunctionService.cs.

public override async Task BackfillMatches(IAsyncStreamReader<BackfillMakeMatchesRequest> requestStream, IServerStreamWriter<BackfillResponse> responseStream, ServerCallContext context)
{
...
}

MakeMatches

Finally, the MakeMatches function completes the process by creating new matches based on the existing player tickets. This function balances minimum and maximum player limits to fill matches as efficiently as possible. It also considers the matchmaking wait time for players who may not meet the criteria for backfilling into existing game sessions.

In the app template, the following function can be found in src/master/src/AccelByte.PluginArch.Demo.Server/Services/MatchFunctionService.cs.

public override async Task MakeMatches(IAsyncStreamReader<MakeMatchesRequest> requestStream, IServerStreamWriter<MatchResponse> responseStream, ServerCallContext context)
{
...
}