Introduction to matchmaking customization
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.
- Go
- C#
- Java
- Python
In the app template, the following function can be found in pkg/server/matchFunctionService.go
.
func (b MatchMaker) GetStatCodes(scope *common.Scope, ruleSet interface{}) []string {
...
}
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)
{
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/matchmaking/function/grpc/server/MatchmakingFunctionService.java
.
@Override
public void getStatCodes(GetStatCodesRequest request, StreamObserver<StatCodesResponse> responseObserver) {
...
}
In the app template, the following function can be found in src/master/src/app/services/matchFunction.py
.
async def GetStatCodes(self, request, 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.
- Go
- C#
- Java
- Python
In the app template, the following function can be found in pkg/server/matchFunctionService.go
.
func (g GameMatchMaker) EnrichTicket(matchTicket matchmaker.Ticket, ruleSet interface{}) (ticket matchmaker.Ticket, err error) {
...
}
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)
{
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/matchmaking/function/grpc/server/MatchmakingFunctionService.java
.
@Override
public void enrichTicket(EnrichTicketRequest request, StreamObserver<EnrichTicketResponse> responseObserver) {
...
}
In the app template, the following function can be found in src/master/src/app/services/matchFunction.py
.
async def EnrichTicket(self, request, 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.
- Go
- C#
- Java
- Python
In the app template, the following function can be found in src/master/pkg/server/matchFunctionService.go
.
func (g GameMatchMaker) ValidateTicket(matchTicket matchmaker.Ticket, matchRules interface{}) (bool, error) {
...
}
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)
{
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/matchmaking/function/grpc/server/MatchmakingFunctionService.java
.
@Override
public void validateTicket(ValidateTicketRequest request, StreamObserver<ValidateTicketResponse> responseObserver) {
...
}
In the app template, the following function can be found in src/master/src/app/services/matchFunction.py
.
async def ValidateTicket(self, request, 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.
- Go
- C#
- Java
- Python
In the app template, the following function can be found in src/master/pkg/server/matchFunctionService.go
.
func (g GameMatchMaker) BackfillMatches(scope *common.Scope, ticketProvider TicketProvider, matchRules interface{}) <-chan matchmaker.BackfillProposal {
...
}
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)
{
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/matchmaking/function/grpc/server/MatchmakingFunctionService.java
.
@Override
public StreamObserver<BackfillMakeMatchesRequest> backfillMatches(StreamObserver<BackfillResponse> responseObserver) {
...
}
In the app template, the following function can be found in src/master/src/app/services/matchFunction.py
.
async def BackfillMatches(self, request_iterator, 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.
- Go
- C#
- Java
- Python
In the app template, the following function can be found in src/master/pkg/server/matchFunctionService.go
.
func (g GameMatchMaker) MakeMatches(ticketProvider TicketProvider, matchRules interface{}) <-chan matchmaker.Match {
...
}
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)
{
...
}
In the app template, the following function can be found in src/main/java/net/accelbyte/matchmaking/function/grpc/server/MatchmakingFunctionService.java
.
@Override
public StreamObserver<MakeMatchesRequest> makeMatches(StreamObserver<MatchResponse> responseObserver) {
...
}
In the app template, the following function can be found in src/master/src/app/services/matchFunction.py
.
async def MakeMatches(self, request_iterator, context):
...