Matchmaker supports invoking Cloud Code modules as a way to integrate with 3rd party hosting providers as highlighted in the Hosting with Cloud Code Modules docs.
Cloud code is priced using the following metrics:
- Invocations
- Compute Hours
- Egress
See UGS Pricing for the Free & Pay as you go details.
Cloud Code Allocator modules require 2 CloudCodeFunction to be available to the matchmaker, these are:
Allocate
[CloudCodeFunction("Matchmaker_AllocateServer")]
public async Task<AllocateResponse> Allocate(IExecutionContext context, AllocateRequest request)This function is expected to Send an allocate request to the 3rd party hosting provider to spin up a server for players to connect to. It should return an allocation ID within the Allocate Response that will be used to check the current state of the allocation request.
Poll
[CloudCodeFunction("Matchmaker_PollAllocation")]
public async Task<PollResponse> Poll(IExecutionContext context, PollRequest request)The poll function will use the allocation ID returned from the Allocate function to check for the state of the server created by the 3rd party hosting provider. This function will continue to be polled until a success or fail state for the server is returned. The Matchmaker will call the Poll function at 2 second intervals.
Based on the above information, this is a summary of how Matchmaker interacts with cloud code and the raised invocations:
- Matchmaker receives incoming tickets and validates the rules on the ticket prioritising existing games through backfill
- If there are no active matches that are valid for the incoming tickets, it will create a new match, requiring a new allocation
- This sends an Allocate Request to the Cloud Code Module (+1 Invocation)
- The matchmaker will then send a Poll Request to the Cloud Code Module every 2 seconds to get the status on the allocation (+1 Invocation for each Poll Request)
- Once the Poll request is returned with a finalized state (Success or Failure), the matchmaker return s the allocated server connection data to the players via their tickets
The matchmaker will not invoke the cloud code module if an existing match is found that a ticket can be added to, and, only one allocate request is made per match - it is not 1 per ticket.