mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-24 08:54:16 +00:00
Fixed AllServers enum option when Finding servers, now searches twice, once for clients, once for dedicated servers.
This is because Steam splits the two queries up and doesn't allow combining them. Added initial Workshop Items support for viewing subscribed items details and information. Former-commit-id: 3153b6dbabf811e864a16408e816df5a03f5c0a3
This commit is contained in:
@@ -12,6 +12,7 @@ UFindSessionsCallbackProxyAdvanced::UFindSessionsCallbackProxyAdvanced(const FOb
|
||||
, Delegate(FOnFindSessionsCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted))
|
||||
, bUseLAN(false)
|
||||
{
|
||||
bRunSecondSearch = false;
|
||||
}
|
||||
|
||||
UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, int MinSlotsAvailable)
|
||||
@@ -40,6 +41,9 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
// Re-initialize here, otherwise I think there might be issues with people re-calling search for some reason before it is destroyed
|
||||
bRunSecondSearch = false;
|
||||
|
||||
DelegateHandle = Sessions->AddOnFindSessionsCompleteDelegate_Handle(Delegate);
|
||||
|
||||
SearchObject = MakeShareable(new FOnlineSessionSearch);
|
||||
@@ -81,6 +85,18 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
||||
if (MinSlotsAvailable != 0)
|
||||
tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals);
|
||||
|
||||
|
||||
|
||||
// Filter results
|
||||
if (SearchSettings.Num() > 0)
|
||||
{
|
||||
for (int i = 0; i < SearchSettings.Num(); i++)
|
||||
{
|
||||
// Function that was added to make directly adding a FVariant possible
|
||||
tem.HardSet(SearchSettings[i].PropertyKeyPair.Key, SearchSettings[i].PropertyKeyPair.Data, SearchSettings[i].ComparisonOp);
|
||||
}
|
||||
}
|
||||
|
||||
switch (ServerSearchType)
|
||||
{
|
||||
|
||||
@@ -99,28 +115,26 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
||||
case EBPServerPresenceSearchType::AllServers:
|
||||
default:
|
||||
{
|
||||
// tem.Set(SEARCH_DEDICATED_ONLY, false, EOnlineComparisonOp::Equals);
|
||||
// tem.Set(SEARCH_PRESENCE, false, EOnlineComparisonOp::Equals);
|
||||
bRunSecondSearch = true;
|
||||
|
||||
SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch);
|
||||
SearchObjectDedicated->MaxSearchResults = MaxResults;
|
||||
SearchObjectDedicated->bIsLanQuery = bUseLAN;
|
||||
|
||||
FOnlineSearchSettingsEx DedicatedOnly = tem;
|
||||
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||
|
||||
DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
||||
SearchObjectDedicated->QuerySettings = DedicatedOnly;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Filter results
|
||||
if (SearchSettings.Num() > 0)
|
||||
{
|
||||
for (int i = 0; i < SearchSettings.Num(); i++)
|
||||
{
|
||||
// Function that was added to make directly adding a FVariant possible
|
||||
tem.HardSet(SearchSettings[i].PropertyKeyPair.Key, SearchSettings[i].PropertyKeyPair.Data, SearchSettings[i].ComparisonOp);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the derived temp variable over to it's base class
|
||||
SearchObject->QuerySettings = tem;
|
||||
|
||||
Sessions->FindSessions(*Helper.UserID, SearchObject.ToSharedRef());
|
||||
|
||||
|
||||
// OnQueryCompleted will get called, nothing more to do now
|
||||
return;
|
||||
}
|
||||
@@ -131,8 +145,7 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
||||
}
|
||||
|
||||
// Fail immediately
|
||||
TArray<FBlueprintSessionResult> Results;
|
||||
OnFailure.Broadcast(Results);
|
||||
OnFailure.Broadcast(SessionSearchResults);
|
||||
}
|
||||
|
||||
void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
||||
@@ -140,7 +153,7 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
||||
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessionsCallback"), GEngine->GetWorldFromContextObject(WorldContextObject));
|
||||
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
|
||||
|
||||
if (Helper.IsValid())
|
||||
if (!bRunSecondSearch && Helper.IsValid())
|
||||
{
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
@@ -149,51 +162,43 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
||||
}
|
||||
}
|
||||
|
||||
TArray<FBlueprintSessionResult> Results;
|
||||
|
||||
if (bSuccess && SearchObject.IsValid())
|
||||
{
|
||||
// Just log the results for now, will need to add a blueprint-compatible search result struct
|
||||
for (auto& Result : SearchObject->SearchResults)
|
||||
{
|
||||
/* bool bAddResult = true;
|
||||
FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs);
|
||||
|
||||
// Filter results
|
||||
if (SearchSettings.Num() > 0)
|
||||
{
|
||||
FOnlineSessionSetting * setting;
|
||||
for (int i = 0; i < SearchSettings.Num(); i++)
|
||||
{
|
||||
setting = Result.Session.SessionSettings.Settings.Find(SearchSettings[i].PropertyKeyPair.Key);
|
||||
FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log);
|
||||
|
||||
// Couldn't find this key
|
||||
if (!setting)
|
||||
continue;
|
||||
|
||||
if (!CompareVariants(setting->Data, SearchSettings[i].PropertyKeyPair.Data, SearchSettings[i].ComparisonOp))
|
||||
{
|
||||
bAddResult = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//if (bAddResult)
|
||||
//{
|
||||
FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs);
|
||||
|
||||
FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log);
|
||||
|
||||
FBlueprintSessionResult BPResult;
|
||||
BPResult.OnlineResult = Result;
|
||||
Results.Add(BPResult);
|
||||
//}
|
||||
FBlueprintSessionResult BPResult;
|
||||
BPResult.OnlineResult = Result;
|
||||
SessionSearchResults.Add(BPResult);
|
||||
}
|
||||
if (!bRunSecondSearch)
|
||||
{
|
||||
OnSuccess.Broadcast(SessionSearchResults);
|
||||
return;
|
||||
}
|
||||
OnSuccess.Broadcast(Results);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnFailure.Broadcast(Results);
|
||||
if (!bRunSecondSearch)
|
||||
{
|
||||
// Need to account for only one of the searches failing
|
||||
if(SessionSearchResults.Num() > 0)
|
||||
OnSuccess.Broadcast(SessionSearchResults);
|
||||
else
|
||||
OnFailure.Broadcast(SessionSearchResults);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (bRunSecondSearch && ServerSearchType == EBPServerPresenceSearchType::AllServers)
|
||||
{
|
||||
bRunSecondSearch = false;
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
Sessions->FindSessions(*Helper.UserID, SearchObjectDedicated.ToSharedRef());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user