Skip to main content

Integrate manually send the dedicated server ready notification

Last updated on April 18, 2024

Overview

info

This guideline is to enable Manual Dedicated Server (DS) Session Ready for the Dedicated Server (DS) flow. The flow on the game client side remains the same.

In your game, you can use the matchmaking, session, and Accelbyte Multiplayers Server (AMS) service out of the box to create an online multiplayer experience for a player. The general AGS Matchmaking flow in shown in the following diagram.

General matchmaking flow

Players submit a matchmaking request to the AccelByte Gaming Services (AGS) Matchmaking service. When tchmaking finds a match, it will create a game session and add the matched players as the session members. The player will get a notification for a match found along with the session information to join. The session service will then claim the Dedicated Server (DS) from the AMS. By default, when the session service successfully claims the DS, it will send a notification to the players with the DS information so that the players can join the DS and start playing the game.

However, in some cases, the DS still needs to do preprocessing or initial tasks before it is ready to accept players. For example, getting information from player attributes, waiting for the additional data to determine what game mode for the players, or pulling the players' statistical information to spawn the enemy level. If the players join the DS during the initial boot-up process, the players could have a bad experience or even be stuck infinitely. In this case, the game developers usually want the DS to decide when to notify the players about the readiness. In these cases, the flow would change to this diagram:

Session manual DS ready flow

Game developers can enable this flow by calling the session service when the DS is ready to accept players. This flow will be explained in more detail in the next section.

Prerequisites

Before following this guideline, you should already have basic knowledge of matchmaking and joining sessions in AGS. Additionally, you should understand the process of configuring matches and sessions in the AGS Admin Portal.

Set up the manual DS session

Configure the Session Template

In our session template, we need to enable the “Manual Set Ready for Dedicated Server (DS)” option.

Configure the manual DS ready from the session template

Require Permission

You will need to add this permission to the IAM Oauth Client for the DS, so that the DS can manually send the DS Session Ready status.

PermissionAction
ADMIN:NAMESPACE:{namespace}:SESSION:GAME[UPDATE]

DS manual session ready permission

Send session ready using AGS Game SDK

Below is the code snippet to send the DS session ready using the AGS OSS. You should call this code after all the DS preparation is done. After the request is sent successfully, the game client should receive a DS status changed notification and be able to join the DS.

FOnlineSessionV2AccelBytePtr SessionInterface;
FOnlineSessionV2AccelByte::GetFromWorld(GetWorld(), SessionInterface);

if (SessionInterface != nullptr)
{
SessionInterface->AddOnSendDSSessionReadyCompleteDelegate_Handle(FOnSendDSSessionReadyCompleteDelegate::CreateLambda([](const FOnlineError& ErrorInfo)
{
if (ErrorInfo.bSucceeded)
{
UE_LOG_AB(Verbose, TEXT("SEND DS READY SUCCESS!!!"));
}
}));

SessionInterface->SendDSSessionReady();
}