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!