> For the complete documentation index, see [llms.txt](https://horizongames.gitbook.io/kronos-matchmaking/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://horizongames.gitbook.io/kronos-matchmaking/usage/matchmaking/joining-matches.md).

# Joining Matches

In order to access online features, the player must be logged in with the **Online Subsystem**. Please visit the [**Authentication**](/kronos-matchmaking/usage/authentication/authenticating-users.md) page for more information.

## Joining Matches Directly

You can directly join a match by using the `JoinKronosMatch` node. Note that you only have to do this if you specifically told the matchmaking system to only search for games. Otherwise players join the game during matchmaking automatically. You will most likely only ever use this for a server browser.

There is no hard requirement on where you need to call this from. Most games will probably have this hooked to the `OnClicked` event of a widget button.

{% tabs %}
{% tab title="Blueprint" %}

<figure><img src="/files/RZOJBjdiOeUFbBL1QhOd" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="C++" %}

```cpp
#include "KronosMatchmakingManager.h"
#include "KronosMatchmakingPolicy.h"
```

```cpp
// The session you want to join. You must get this somehow, for example by doing a SearchOnly matchmaking.
// Please note that search results cannot be replicated or sent via RPCs! This is an Online Subsystem limitation.
// Notice that this is passed into the lambda so that we can access it.
FKronosSearchResult SessionToJoin;

// Get the matchmaking manager.
UKronosMatchmakingManager* MatchmakingManager = UKronosMatchmakingManager::Get(this);

// Request a new matchmaking policy. This operation is async!
// If matchmaking is in-progress, it will be canceled first.
MatchmakingManager->CreateMatchmakingPolicy(FOnCreateMatchmakingPolicyComplete::CreateLambda([this, SessionToJoin](UKronosMatchmakingPolicy* MatchmakingPolicy)
{
    // Matchmaking params are irrelevant in JoinOnly mode.
    FKronosMatchmakingParams MatchmakingParams = FKronosMatchmakingParams();

    // Matchmaking flags to use.
    uint8 MatchmakingFlags = static_cast<uint8>(EKronosMatchmakingFlags::None);

    // Tell the matchmaking that we only want to join a session that we've got already.
    EKronosMatchmakingMode MatchmakingMode = EKronosMatchmakingMode::JoinOnly;

    // Start matchmaking.
    // Notice that we are using NAME_GameSession!
    MatchmakingPolicy->StartMatchmaking(NAME_GameSession, MatchmakingParams, MatchmakingFlags, MatchmakingMode, 0.0f, SessionToJoin);
}));
```

{% endtab %}
{% endtabs %}

## Finding Matches To Join

You find matches by using the `FindKronosMatches` node. This will give you an array of `KronosSearchResult` that you can iterate over (e.g. to create entries for a server browser).

There is no hard requirement on where you need to call this from. Most games will probably have this hooked to the `OnClicked` event of a widget button.

{% tabs %}
{% tab title="Blueprint" %}

<figure><img src="/files/paQxA28I225e7MLmS4Il" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="C++" %}

```cpp
#include "KronosMatchmakingManager.h"
#include "KronosPartyManager.h"
#include "KronosMatchmakingPolicy.h"
```

```cpp
// Get the matchmaking manager.
UKronosMatchmakingManager* MatchmakingManager = UKronosMatchmakingManager::Get(this);

// Request a new matchmaking policy. This operation is async!
// If matchmaking is in-progress, it will be canceled first.
MatchmakingManager->CreateMatchmakingPolicy(FOnCreateMatchmakingPolicyComplete::CreateLambda([this](UKronosMatchmakingPolicy* MatchmakingPolicy)
{
    // Parameters to be used for matchmaking.
    FKronosMatchmakingParams MatchmakingParams;
    MatchmakingParams.Playlist = TEXT("TeamDeathmatch");
    MatchmakingParams.MaxSearchAttempts = 3;
    MatchmakingParams.MaxSearchResults = 20;
    MatchmakingParams.MinSlotsRequired = 0;
    MatchmakingParams.bIsLanQuery = false;
    MatchmakingParams.bSearchPresence = true;
    
    // Matchmaking flags to use.
    // You could use EKronosMatchmakingFlags::SkipEloChecks.
    uint8 MatchmakingFlags = static_cast<uint8>(EKronosMatchmakingFlags::None);
    
    // Tell the matchmaking that we only want to search for sessions.
    EKronosMatchmakingMode MatchmakingMode = EKronosMatchmakingMode::SearchOnly;
    
    // Start matchmaking.
    // Notice that we are using NAME_GameSession!
    MatchmakingPolicy->StartMatchmaking(NAME_GameSession, MatchmakingParams, MatchmakingFlags, MatchmakingMode);
}));
```

{% endtab %}
{% endtabs %}
