Skip to main content

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.

  1. Open the CustomMatchmakingWidget_Starter CPP file, go to StartMatchmaking 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();
}
  1. 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();
}
  1. 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);
}
  1. 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