Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "SpatialGameInstance.h"
#include "TimerManager.h"
#include "SpatialGDKSettings.h"
#include "SpatialWorkerConnection.h"

#include "GDKLogging.h"
Expand All @@ -18,6 +19,12 @@ void ADeploymentsPlayerController::BeginPlay()
USpatialGameInstance* SpatialGameInstance = GetGameInstance<USpatialGameInstance>();
SpatialWorkerConnection = SpatialGameInstance->GetSpatialWorkerConnection();

if (SpatialWorkerConnection == nullptr)
{
// We might not be using spatial networking in which case SpatialWorkerConnection will not exist so we should just return
return;
}

FString SpatialWorkerType = SpatialGameInstance->GetSpatialWorkerType().ToString();
SpatialWorkerConnection->RegisterOnLoginTokensCallback([this](const Worker_Alpha_LoginTokensResponse* Deployments){
Populate(Deployments);
Expand All @@ -28,7 +35,10 @@ void ADeploymentsPlayerController::BeginPlay()
return true;
});

SpatialWorkerConnection->Connect(true, 0);
if (GetDefault<USpatialGDKSettings>()->bUseDevelopmentAuthenticationFlow)
{
SpatialWorkerConnection->Connect(true, 0);
}
}

void ADeploymentsPlayerController::EndPlay(const EEndPlayReason::Type Reason)
Expand Down
6 changes: 6 additions & 0 deletions Game/Source/GDKShooter/Private/UI/GDKWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Components/ControllerEventsComponent.h"
#include "Components/GDKMovementComponent.h"
#include "Components/HealthComponent.h"
#include "EngineClasses/SpatialGameInstance.h"
#include "Game/Components/LobbyTimerComponent.h"
#include "Game/Components/MatchTimerComponent.h"
#include "Game/Components/PlayerCountingComponent.h"
Expand Down Expand Up @@ -106,6 +107,11 @@ void UGDKWidget::LeaveGame(const FString& TargetMap)
FURL TravelURL;
TravelURL.Map = *TargetMap;

if (USpatialGameInstance* GameInstance = Cast<USpatialGameInstance>(GetGameInstance()))
{
GameInstance->GetSpatialWorkerConnection()->DestroyConnection();
}

GetOwningPlayer()->ClientTravel(TravelURL.ToString(), TRAVEL_Absolute, false /*bSeamless*/);

}
Expand Down