Leave Matchmaking #

This topic provides instructions on how to handle parties when they leave matchmaking.

Leave matchmaking from the player client #

Exit the matchmaking process using the API for Unreal or Unity

Players can request that their party leave matchmaking by invoking the Party API’s LeaveMatchmaking() method. This action removes the player’s whole party from the matchmaking service.

Player->PartyApi()->LeaveMatchmaking(
  const FOnCompleteDelegate& OnComplete
)
player.PartyApi.LeaveMatchmaking(
  CompleteDelegate onComplete
)
{
  "requestId": 15,
  "type": "matchmakingRpc.LeaveMatchmakingV2Request",
  "payload": {
  }
}

After the player and their party are removed from matchmaking, players receive a OnLeftMatchmaking event. The PartyApi.LeaveMatchmaking() function also triggers the Party Plugin’s returnFromMatchmaking() method, which provides a way to handle players and parties leaving matchmaking.

Leave matchmaking from the game server #

Game servers can request that an active game instance leave matchmaking by invoking MatchApi.LeaveMatchmaking().

Player->MatchApi()->LeaveMatchmaking(
  const FString& GameInstanceId,
  const FOnCompleteDelegate& OnComplete
)
player.MatchApi.LeaveMatchmaking(
  PragmaId gameInstanceId,
  CompleteDelegate onComplete
)
{
  "requestId": 16,
  "type": "matchmakingRpc.LeaveMatchmakingV2Request",
  "payload": {
  }
}

After the game instance is removed from matchmaking, the game server receive a OnGameInstanceLeftMatchmaking event.

Return from matchmaking #

Process matchmaking instance exit scenarios

When players leave matchmaking, the Party plugin’s returnFromMatchmaking() method is invoked. Use this method to perform any necessary updates to player or party states. In the following example, we use this method to update the players’ rich presence.

override suspend fun returnFromMatchmaking(
    party: Party,
    returningPlayers: List<PartyPlayer>,
    config: PartyConfig
) {
    returningPlayers.forEach { player ->
        val extBackendRich: ExtRichPresenceBackendRequest = ExtRichPresenceBackendRequest
            .newBuilder()
            .setClearInMatchmaking(true)
            .build()
        presenceApi.setRichPresence(player.playerId, extBackendRich)
    }
}

Related events:

Related errors:

  • PartyService_NotInParty
  • PartyService_PlayerNotLeader
  • PartyService_PlayersNotReady
  • PartyService_GameServerNoLongerCompatible
  • PartyService_FailedToEnterMatchmaking