mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-23 00:14:24 +00:00
Fix: Issue #18 Update session not finding sessions to update
This commit is contained in:
@@ -29,70 +29,73 @@ UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::Update
|
|||||||
|
|
||||||
void UUpdateSessionCallbackProxyAdvanced::Activate()
|
void UUpdateSessionCallbackProxyAdvanced::Activate()
|
||||||
{
|
{
|
||||||
|
const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSession"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
|
||||||
|
|
||||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld());
|
if (Helper.OnlineSub != nullptr)
|
||||||
|
|
||||||
if (Sessions.IsValid())
|
|
||||||
{
|
{
|
||||||
if (Sessions->GetNumSessions() < 1)
|
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||||
|
if (Sessions.IsValid())
|
||||||
{
|
{
|
||||||
OnFailure.Broadcast();
|
if (Sessions->GetNumSessions() < 1)
|
||||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("NO REGISTERED SESSIONS!"));
|
{
|
||||||
|
OnFailure.Broadcast();
|
||||||
|
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("NO REGISTERED SESSIONS!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This gets the actual session itself
|
||||||
|
//FNamedOnlineSession * curSession = Sessions->GetNamedSession(NAME_GameSession);
|
||||||
|
FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(NAME_GameSession);
|
||||||
|
|
||||||
|
if (!Settings)
|
||||||
|
{
|
||||||
|
// Fail immediately
|
||||||
|
OnFailure.Broadcast();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnUpdateSessionCompleteDelegateHandle = Sessions->AddOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegate);
|
||||||
|
|
||||||
|
// FOnlineSessionSettings Settings;
|
||||||
|
//Settings->BuildUniqueId = GetBuildUniqueId();
|
||||||
|
Settings->NumPublicConnections = NumPublicConnections;
|
||||||
|
Settings->NumPrivateConnections = NumPrivateConnections;
|
||||||
|
//Settings->bShouldAdvertise = true;
|
||||||
|
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
|
||||||
|
Settings->bIsLANMatch = bUseLAN;
|
||||||
|
//Settings->bUsesPresence = true;
|
||||||
|
//Settings->bAllowJoinViaPresence = true;
|
||||||
|
Settings->bAllowInvites = bAllowInvites;
|
||||||
|
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
|
||||||
|
Settings->bIsDedicated = bDedicatedServer;
|
||||||
|
|
||||||
|
FOnlineSessionSetting * fSetting = NULL;
|
||||||
|
FOnlineSessionSetting ExtraSetting;
|
||||||
|
for (int i = 0; i < ExtraSettings.Num(); i++)
|
||||||
|
{
|
||||||
|
fSetting = Settings->Settings.Find(ExtraSettings[i].Key);
|
||||||
|
|
||||||
|
if (fSetting)
|
||||||
|
{
|
||||||
|
fSetting->Data = ExtraSettings[i].Data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExtraSetting.Data = ExtraSettings[i].Data;
|
||||||
|
ExtraSetting.AdvertisementType = EOnlineDataAdvertisementType::ViaOnlineService;
|
||||||
|
Settings->Settings.Add(ExtraSettings[i].Key, ExtraSetting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Sessions->UpdateSession(NAME_GameSession, *Settings, bRefreshOnlineData);
|
||||||
|
|
||||||
|
// OnUpdateCompleted will get called, nothing more to do now
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// This gets the actual session itself
|
|
||||||
//FNamedOnlineSession * curSession = Sessions->GetNamedSession(NAME_GameSession);
|
|
||||||
FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(NAME_GameSession);
|
|
||||||
|
|
||||||
if (!Settings)
|
|
||||||
{
|
{
|
||||||
// Fail immediately
|
FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
|
||||||
OnFailure.Broadcast();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnUpdateSessionCompleteDelegateHandle = Sessions->AddOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegate);
|
|
||||||
|
|
||||||
// FOnlineSessionSettings Settings;
|
|
||||||
//Settings->BuildUniqueId = GetBuildUniqueId();
|
|
||||||
Settings->NumPublicConnections = NumPublicConnections;
|
|
||||||
Settings->NumPrivateConnections = NumPrivateConnections;
|
|
||||||
//Settings->bShouldAdvertise = true;
|
|
||||||
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
|
|
||||||
Settings->bIsLANMatch = bUseLAN;
|
|
||||||
//Settings->bUsesPresence = true;
|
|
||||||
//Settings->bAllowJoinViaPresence = true;
|
|
||||||
Settings->bAllowInvites = bAllowInvites;
|
|
||||||
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
|
|
||||||
Settings->bIsDedicated = bDedicatedServer;
|
|
||||||
|
|
||||||
FOnlineSessionSetting * fSetting = NULL;
|
|
||||||
FOnlineSessionSetting ExtraSetting;
|
|
||||||
for (int i = 0; i < ExtraSettings.Num(); i++)
|
|
||||||
{
|
|
||||||
fSetting = Settings->Settings.Find(ExtraSettings[i].Key);
|
|
||||||
|
|
||||||
if (fSetting)
|
|
||||||
{
|
|
||||||
fSetting->Data = ExtraSettings[i].Data;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ExtraSetting.Data = ExtraSettings[i].Data;
|
|
||||||
ExtraSetting.AdvertisementType = EOnlineDataAdvertisementType::ViaOnlineService;
|
|
||||||
Settings->Settings.Add(ExtraSettings[i].Key, ExtraSetting);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Sessions->UpdateSession(NAME_GameSession, *Settings, bRefreshOnlineData);
|
|
||||||
|
|
||||||
// OnUpdateCompleted will get called, nothing more to do now
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
|
|
||||||
}
|
}
|
||||||
// Fail immediately
|
// Fail immediately
|
||||||
OnFailure.Broadcast();
|
OnFailure.Broadcast();
|
||||||
@@ -101,15 +104,20 @@ void UUpdateSessionCallbackProxyAdvanced::Activate()
|
|||||||
|
|
||||||
void UUpdateSessionCallbackProxyAdvanced::OnUpdateCompleted(FName SessionName, bool bWasSuccessful)
|
void UUpdateSessionCallbackProxyAdvanced::OnUpdateCompleted(FName SessionName, bool bWasSuccessful)
|
||||||
{
|
{
|
||||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld());
|
const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
|
||||||
if (Sessions.IsValid())
|
|
||||||
|
if (Helper.OnlineSub != nullptr)
|
||||||
{
|
{
|
||||||
Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle);
|
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||||
|
if (Sessions.IsValid())
|
||||||
if (bWasSuccessful)
|
|
||||||
{
|
{
|
||||||
OnSuccess.Broadcast();
|
Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle);
|
||||||
return;
|
|
||||||
|
if (bWasSuccessful)
|
||||||
|
{
|
||||||
|
OnSuccess.Broadcast();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user