0

I’m trying make a connection by EOS, I am creating a session with success, but the other app can’t find this session. I see in the EOS Dev Portal the session created.

Here is the create session method:

void UEOS_GameInstance::CreateEOSSession(bool bIsDedicatedServer, bool bIsLanServer, int32 NumberOfPublicConnections)
{
    IOnlineSubsystem* SubsystemRef = Online::GetSubsystem(this->GetWorld());

    if (SubsystemRef)
    {
        IOnlineSessionPtr SessionPtrRef = SubsystemRef->GetSessionInterface();
        if (SessionPtrRef)
        {
            FOnlineSessionSettings SessionCreationInfo;
            SessionCreationInfo.bIsDedicated = bIsDedicatedServer;
            SessionCreationInfo.bAllowInvites = true;
            SessionCreationInfo.bIsLANMatch = bIsLanServer;
            SessionCreationInfo.NumPublicConnections = NumberOfPublicConnections;
            SessionCreationInfo.bUseLobbiesIfAvailable = true;
            SessionCreationInfo.bUsesPresence = true;
            SessionCreationInfo.bShouldAdvertise = true;
            SessionCreationInfo.Set(SEARCH_KEYWORDS, FString("RandonHi"), EOnlineDataAdvertisementType::ViaOnlineServiceAndPing);

            SessionPtrRef->OnCreateSessionCompleteDelegates.AddUObject(this, &UEOS_GameInstance::OnCreateSessionCompleted);

            SessionPtrRef->CreateSession(0, FName("MainSession"), SessionCreationInfo);         
        }
    }
}

Here is the find and join session method:

void UEOS_GameInstance::FindSessionAndJoin()
{
    UE_LOG(LogTemp, Warning, TEXT("Try find session"));

    IOnlineSubsystem* SubsystemRef = Online::GetSubsystem(this->GetWorld());

    FString SubsystemName = SubsystemRef->GetSubsystemName().ToString();

    UE_LOG(LogTemp, Warning, TEXT("Is Null subsystem %s"), *SubsystemName);

    if (SubsystemRef)
    {
        IOnlineSessionPtr SessionPtrRef = SubsystemRef->GetSessionInterface();
        if (SessionPtrRef)
        {
            UE_LOG(LogTemp, Warning, TEXT("Making SearchQuerry"));
            SessionSearch = MakeShareable(new FOnlineSessionSearch());
            SessionSearch->bIsLanQuery = false;
            SessionSearch->MaxSearchResults = 20;
            SessionSearch->QuerySettings.SearchParams.Empty();
            //SessionSearch->QuerySettings.Set(SEARCH_KEYWORDS, FString("RandonHi"), EOnlineComparisonOp::Equals);
            SessionPtrRef->OnFindSessionsCompleteDelegates.AddUObject(this, &UEOS_GameInstance::OnFindSessionCompleted);
            SessionPtrRef->FindSessions(0, SessionSearch.ToSharedRef());
        }
    }
}

Here is the callback of the find method:

void UEOS_GameInstance::OnFindSessionCompleted(bool bWasSuccess)
{
    if (bWasSuccess)
    {
        UE_LOG(LogTemp, Warning, TEXT("Session found completed"));

        IOnlineSubsystem* SubsystemRef = Online::GetSubsystem(this->GetWorld());

        if (SubsystemRef)
        {
            IOnlineSessionPtr SessionPtrRef = SubsystemRef->GetSessionInterface();
            if (SessionPtrRef)
            {
                if (SessionSearch->SearchResults.Num() > 0)
                {
                    UE_LOG(LogTemp, Warning, TEXT("Session found 1"));
                    SessionPtrRef->OnJoinSessionCompleteDelegates.AddUObject(this, &UEOS_GameInstance::OnJoinSessionCompleted);
                    UE_LOG(LogTemp, Warning, TEXT("Try Join Session"));
                    SessionPtrRef->JoinSession(0, FName("MainSession"), SessionSearch->SearchResults[0]);
                }
                else
                {
                    UE_LOG(LogTemp, Warning, TEXT("Session found 0"));
                    //CreateEOSSession(false, false, 3);
                }
            }
        }
    }
    else
    {
        UE_LOG(LogTemp, Warning, TEXT("Session not found, trying create one!"));
        //CreateEOSSession(false, false, 3);
    }
}

All times I get in the log Session found 0 .

Thanks for your help!

InfJ
  • 43
  • 1
  • 5

1 Answers1

0

I fixed the problem, first in the create Sessions I modified some things:

FOnlineSessionSettings SessionCreationInfo;
        SessionCreationInfo.bIsDedicated = bIsDedicatedServer;
        SessionCreationInfo.bAllowInvites = true;
        SessionCreationInfo.bIsLANMatch = false;
        SessionCreationInfo.NumPublicConnections = NumberOfPublicConnections;
        SessionCreationInfo.bUseLobbiesIfAvailable = false;
        SessionCreationInfo.bUsesPresence = false;
        SessionCreationInfo.bShouldAdvertise = true;
        SessionCreationInfo.Set(SEARCH_KEYWORDS, FString("RandonHi"), EOnlineDataAdvertisementType::ViaOnlineServiceAndPing);

After that I put a packed client into my notebook connected by my 4G to do not have the same IP of my desktop that was connected in my fiber connection and created a new session in there (Notebook), after that I tried to connect from an app started in the desktop and it connected!

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
InfJ
  • 43
  • 1
  • 5