cannot convert argument 1 from 'TSharedPtr<const FUniqueNetId,0>' to 'ULocalPlayer *'

I get a compiler error that highlights the “pid” in JoinGame and the “->” in between of “Sessions->JoinSession”.

Saying: E0304 no instance of overloaded function “IOnlineSession::JoinSession” matches the argument list

Error C2661 ‘IOnlineSession::JoinSession’: no overloaded function takes 2 arguments

And: Error C2664 ‘bool UPlatformerGameInstance::JoinSession(ULocalPlayer *,const FOnlineSessionSearchResult &)’: cannot convert argument 1 from ‘TSharedPtr<const FUniqueNetId,0>’ to ‘ULocalPlayer *’

(There is a red line under the bolded parts in visual studio)

PlatformerGameInstance.cpp


void UPlatformerGameInstance::JoinGame(FBlueprintSearchResult result)
{

    IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();

    if (OnlineSub) {

        TSharedPtr<const FUniqueNetId> pid = OnlineSub->GetIdentityInterface()->GetUniquePlayerId(0);

        JoinSession(**pid**, result.result);
    }
}

bool UPlatformerGameInstance::JoinSession(ULocalPlayer* UserId, const FOnlineSessionSearchResult& SearchResult)
{
    bool bSuccessful = false;

    IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();

    if (OnlineSub) {

        IOnlineSessionPtr Sessions = OnlineSub->GetSessionInterface();

        if (Sessions.IsValid() && UserId->GetPreferredUniqueNetId().GetUniqueNetId().IsValid()) {

            OnJoinSessionCompleteDelegateHandle = Sessions->AddOnJoinSessionCompleteDelegate_Handle(OnJoinSessionCompleteDelegate);

            bSuccessful = Sessions**->**JoinSession(*UserId, SearchResult);
        }
    }
    return bSuccessful;
}

In the Shooter Game example, there are 2 JoinSession functions and they use old code like TSharedPtr UserId when the newer ULocalPlayer works for newer versions.

Shooter Game: ShooterGameInstance.cpp


bool UShooterGameInstance::JoinSession(ULocalPlayer* LocalPlayer, int32 SessionIndexInSearchResults)
{
    // needs to tear anything down based on current state?

    AShooterGameSession* const GameSession = GetGameSession();
    if (GameSession)
    {
        AddNetworkFailureHandlers();

        OnJoinSessionCompleteDelegateHandle = GameSession->OnJoinSessionComplete().AddUObject(this, &UShooterGameInstance::OnJoinSessionComplete);
        if (GameSession->JoinSession(LocalPlayer->GetPreferredUniqueNetId().GetUniqueNetId(), NAME_GameSession, SessionIndexInSearchResults))
        {
            // If any error occured in the above, pending state would be set
            if ( (PendingState == CurrentState) || (PendingState == ShooterGameInstanceState::None) )
            {
                // Go ahead and go into loading state now
                // If we fail, the delegate will handle showing the proper messaging and move to the correct state
                ShowLoadingScreen();
                GotoState(ShooterGameInstanceState::Playing);
                return true;
            }
        }
    }

    return false;
}

bool UShooterGameInstance::JoinSession(ULocalPlayer* LocalPlayer, const FOnlineSessionSearchResult& SearchResult)
{
    // needs to tear anything down based on current state?
    AShooterGameSession* const GameSession = GetGameSession();
    if (GameSession)
    {
        AddNetworkFailureHandlers();

        OnJoinSessionCompleteDelegateHandle = GameSession->OnJoinSessionComplete().AddUObject(this, &UShooterGameInstance::OnJoinSessionComplete);
        if (GameSession->JoinSession(LocalPlayer->GetPreferredUniqueNetId().GetUniqueNetId(), NAME_GameSession, SearchResult))
        {
            // If any error occured in the above, pending state would be set
            if ( (PendingState == CurrentState) || (PendingState == ShooterGameInstanceState::None) )
            {
                // Go ahead and go into loading state now
                // If we fail, the delegate will handle showing the proper messaging and move to the correct state
                ShowLoadingScreen();
                GotoState(ShooterGameInstanceState::Playing);
                return true;
            }
        }
    }

    return false;
}