Put it all together - Game client integration - (Unreal Engine module)
Last updated on March 12, 2025
Connect the UI to custom matchmaking
In this section, you will use the custom matchmaking menu with the subsystem you created previously to connect the game client to the sample matchmaking backend service.
- Open the
CustomMatchmakingWidget_Starter
CPP file, go toStartMatchmaking
function, and add the following function call to the end of the function. This starts the actual start matchmaking process.
void UCustomMatchmakingWidget_Starter::StartMatchmaking()
{
// ...
Subsystem->StartMatchmaking();
}
- Go to
StopMatchmaking
function and add the following function call to the end of the function. This stops and disconnects the game from the matchmaking server.
void UCustomMatchmakingWidget_Starter::StopMatchmaking()
{
// ...
Subsystem->StopMatchmaking();
}
- Go to the
NativeOnActivated
function and add the following code to the end of the function. This will connect the UI to the matchmaking events right after the menu opens.
void UCustomMatchmakingWidget_Starter::NativeOnActivated()
{
// ...
// Bind events
Subsystem->OnMatchmakingStartedDelegates.AddUObject(this, &ThisClass::OnMatchmakingStarted);
Subsystem->OnMatchmakingErrorDelegates.AddUObject(this, &ThisClass::OnMatchmakingFailed);
Subsystem->OnMatchmakingMessageReceivedDelegates.AddUObject(this, &ThisClass::OnMessageReceived);
Subsystem->OnMatchmakingStoppedDelegates.AddUObject(this, &ThisClass::OnMatchmakingFailed);
}
- Lastly, go to
NativeOnDeactivated
function and add the following code to the end of the function. This will disconnect the UI from the matchmaking events as soon as the menu closes.
void UCustomMatchmakingWidget_Starter::NativeOnDeactivated()
{
// ...
// Unbind events
Subsystem->OnMatchmakingStartedDelegates.RemoveAll(this);
Subsystem->OnMatchmakingErrorDelegates.RemoveAll(this);
Subsystem->OnMatchmakingMessageReceivedDelegates.RemoveAll(this);
Subsystem->OnMatchmakingStoppedDelegates.RemoveAll(this);
}
Resources
- The files used in this tutorial section are available in the Byte Wars Unreal GitHub repository.