-
Notifications
You must be signed in to change notification settings - Fork 30
Merge of MBL-19 #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Merge of MBL-19 #108
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,79 +15,27 @@ void ADeploymentsPlayerController::BeginPlay() | |
|
||
bShowMouseCursor = true; | ||
|
||
QueryPIT(); | ||
} | ||
|
||
void ADeploymentsPlayerController::EndPlay(const EEndPlayReason::Type Reason) | ||
{ | ||
GetWorld()->GetTimerManager().ClearAllTimersForObject(this); | ||
} | ||
|
||
void OnLoginTokens(void* UserData, const Worker_Alpha_LoginTokensResponse* LoginTokens) | ||
{ | ||
ADeploymentsPlayerController* contoller = static_cast<ADeploymentsPlayerController*>(UserData); | ||
if (LoginTokens->status.code == WORKER_CONNECTION_STATUS_CODE_SUCCESS) | ||
{ | ||
UE_LOG(LogGDK, Log, TEXT("Success: Login Token Count %d"), LoginTokens->login_token_count); | ||
contoller->Populate(LoginTokens); | ||
} | ||
else | ||
{ | ||
UE_LOG(LogGDK, Log, TEXT("Failure: Error %s"), UTF8_TO_TCHAR(LoginTokens->status.detail)); | ||
} | ||
} | ||
|
||
void OnPlayerIdentityToken(void* UserData, const Worker_Alpha_PlayerIdentityTokenResponse* PIToken) | ||
{ | ||
if (PIToken->status.code == WORKER_CONNECTION_STATUS_CODE_SUCCESS) | ||
{ | ||
UE_LOG(LogGDK, Log, TEXT("Success: Received PIToken: %s"), UTF8_TO_TCHAR(PIToken->player_identity_token)); | ||
ADeploymentsPlayerController* controller = static_cast<ADeploymentsPlayerController*>(UserData); | ||
controller->LatestPITokenData = PIToken->player_identity_token; | ||
controller->LatestPIToken = UTF8_TO_TCHAR(PIToken->player_identity_token); | ||
|
||
if (!controller->GetWorld()->GetTimerManager().IsTimerActive(controller->QueryDeploymentsTimer)) | ||
{ | ||
controller->GetWorld()->GetTimerManager().SetTimer(controller->QueryDeploymentsTimer, controller, &ADeploymentsPlayerController::QueryDeployments, 5.0f, true, 0.0f); | ||
} | ||
} | ||
else | ||
{ | ||
UE_LOG(LogGDK, Log, TEXT("Failure: Error %s"), UTF8_TO_TCHAR(PIToken->status.detail)); | ||
ADeploymentsPlayerController* controller = static_cast<ADeploymentsPlayerController*>(UserData); | ||
USpatialGameInstance* SpatialGameInstance = GetGameInstance<USpatialGameInstance>(); | ||
SpatialWorkerConnection = SpatialGameInstance->GetSpatialWorkerConnection(); | ||
|
||
if (controller->GetWorld()->GetTimerManager().IsTimerActive(controller->QueryDeploymentsTimer)) | ||
FString SpatialWorkerType = SpatialGameInstance->GetSpatialWorkerType().ToString(); | ||
SpatialWorkerConnection->RegisterOnLoginTokensCallback([this](const Worker_Alpha_LoginTokensResponse* Deployments){ | ||
Populate(Deployments); | ||
if (!GetWorld()->GetTimerManager().IsTimerActive(QueryDeploymentsTimer)) | ||
{ | ||
controller->GetWorld()->GetTimerManager().ClearTimer(controller->QueryDeploymentsTimer); | ||
GetWorld()->GetTimerManager().SetTimer(QueryDeploymentsTimer, this, &ADeploymentsPlayerController::ScheduleRefreshDeployments, 10.0f, true, 0.0f); | ||
} | ||
} | ||
} | ||
|
||
void ADeploymentsPlayerController::QueryDeployments() | ||
{ | ||
Worker_Alpha_LoginTokensRequest* LTParams = new Worker_Alpha_LoginTokensRequest(); | ||
LTParams->player_identity_token = LatestPITokenData; | ||
LTParams->worker_type = "UnrealClient"; | ||
Worker_Alpha_LoginTokensResponseFuture* LTFuture = Worker_Alpha_CreateDevelopmentLoginTokensAsync("locator.improbable.io", 444, LTParams); | ||
Worker_Alpha_LoginTokensResponseFuture_Get(LTFuture, nullptr, this, OnLoginTokens); | ||
return true; | ||
}); | ||
|
||
SpatialWorkerConnection->Connect(true); | ||
} | ||
|
||
void ADeploymentsPlayerController::QueryPIT() | ||
void ADeploymentsPlayerController::EndPlay(const EEndPlayReason::Type Reason) | ||
{ | ||
Worker_Alpha_PlayerIdentityTokenRequest* PITParams = new Worker_Alpha_PlayerIdentityTokenRequest(); | ||
// Replace this string with a dev auth token, see docs for information on how to generate one of these | ||
PITParams->development_authentication_token = "REPLACE ME"; | ||
PITParams->player_id = "Player Id"; | ||
PITParams->display_name = ""; | ||
PITParams->metadata = ""; | ||
PITParams->use_insecure_connection = false; | ||
|
||
Worker_Alpha_PlayerIdentityTokenResponseFuture* PITFuture = Worker_Alpha_CreateDevelopmentPlayerIdentityTokenAsync("locator.improbable.io", 444, PITParams); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here as well, also might need to double check the port |
||
|
||
if (PITFuture != nullptr) | ||
{ | ||
Worker_Alpha_PlayerIdentityTokenResponseFuture_Get(PITFuture, nullptr, this, OnPlayerIdentityToken); | ||
} | ||
if (SpatialWorkerConnection != nullptr) | ||
SpatialWorkerConnection->RegisterOnLoginTokensCallback([](const Worker_Alpha_LoginTokensResponse* Deployments){return false;}); | ||
GetWorld()->GetTimerManager().ClearAllTimersForObject(this); | ||
} | ||
|
||
FDeploymentInfo Parse(const Worker_Alpha_LoginTokenDetails LoginToken) | ||
|
@@ -137,12 +85,19 @@ void ADeploymentsPlayerController::Populate(const Worker_Alpha_LoginTokensRespon | |
|
||
void ADeploymentsPlayerController::JoinDeployment(const FString& LoginToken) | ||
{ | ||
if (SpatialWorkerConnection == nullptr) | ||
{ | ||
UE_LOG(LogGDK, Error, TEXT("Failure: failed to Join Deployment caused by SpatialWorkerConnection is nullptr")); | ||
return; | ||
} | ||
|
||
const FLocatorConfig& LocatorConfig = SpatialWorkerConnection->LocatorConfig; | ||
FURL TravelURL; | ||
TravelURL.Host = TEXT("locator.improbable.io"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is the line that I think is causing the issues in the linked jira ticket. |
||
TravelURL.Host = LocatorConfig.LocatorHost; | ||
TravelURL.AddOption(TEXT("locator")); | ||
TravelURL.AddOption(*FString::Printf(TEXT("playeridentity=%s"), *LatestPIToken)); | ||
TravelURL.AddOption(*FString::Printf(TEXT("playeridentity=%s"), *LocatorConfig.PlayerIdentityToken)); | ||
TravelURL.AddOption(*FString::Printf(TEXT("login=%s"), *LoginToken)); | ||
|
||
OnLoadingStarted.Broadcast(); | ||
|
||
ClientTravel(TravelURL.ToString(), TRAVEL_Absolute, false); | ||
|
@@ -152,3 +107,9 @@ void ADeploymentsPlayerController::SetLoadingScreen(UUserWidget* LoadingScreen) | |
{ | ||
GetGameInstance()->GetGameViewportClient()->AddViewportWidgetContent(LoadingScreen->TakeWidget()); | ||
} | ||
|
||
void ADeploymentsPlayerController::ScheduleRefreshDeployments() | ||
{ | ||
if (SpatialWorkerConnection != nullptr) | ||
SpatialWorkerConnection->RequestDeploymentLoginTokens(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here