Add GameInstance for Global Session ID
This commit is contained in:
parent
61018a044d
commit
d34b52f972
@ -67,7 +67,7 @@ TwoPlayerSplitscreenLayout=Horizontal
|
|||||||
ThreePlayerSplitscreenLayout=FavorTop
|
ThreePlayerSplitscreenLayout=FavorTop
|
||||||
FourPlayerSplitscreenLayout=Grid
|
FourPlayerSplitscreenLayout=Grid
|
||||||
bOffsetPlayerGamepadIds=False
|
bOffsetPlayerGamepadIds=False
|
||||||
GameInstanceClass=/Script/Engine.GameInstance
|
GameInstanceClass=/Script/EndlessVendetta.EVGameInstance
|
||||||
GameDefaultMap=/Game/Levels/TrainingFacility.TrainingFacility
|
GameDefaultMap=/Game/Levels/TrainingFacility.TrainingFacility
|
||||||
ServerDefaultMap=/Engine/Maps/Entry.Entry
|
ServerDefaultMap=/Engine/Maps/Entry.Entry
|
||||||
GlobalDefaultGameMode=/Script/EndlessVendetta.EndlessVendettaGameMode
|
GlobalDefaultGameMode=/Script/EndlessVendetta.EndlessVendettaGameMode
|
||||||
|
BIN
EndlessVendetta/Content/Levels/TrainingFacility.umap
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Levels/TrainingFacility.umap
(Stored with Git LFS)
Binary file not shown.
@ -9,7 +9,6 @@
|
|||||||
#include "Perception/AIPerceptionStimuliSourceComponent.h"
|
#include "Perception/AIPerceptionStimuliSourceComponent.h"
|
||||||
#include "Perception/AISense_Sight.h"
|
#include "Perception/AISense_Sight.h"
|
||||||
#include "BehaviorTree/BlackboardComponent.h"
|
#include "BehaviorTree/BlackboardComponent.h"
|
||||||
#include "../Telemetry.h"
|
|
||||||
#include <EndlessVendetta/EndlessVendettaGameMode.h>
|
#include <EndlessVendetta/EndlessVendettaGameMode.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "WaypointActor.h"
|
#include "WaypointActor.h"
|
||||||
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
||||||
#include "EndlessVendetta/Telemetry.h"
|
|
||||||
#include "GameFramework/Actor.h"
|
#include "GameFramework/Actor.h"
|
||||||
#include <EndlessVendetta/EndlessVendettaGameMode.h>
|
#include <EndlessVendetta/EndlessVendettaGameMode.h>
|
||||||
#include "CheckpointClass.generated.h"
|
#include "CheckpointClass.generated.h"
|
||||||
|
32
EndlessVendetta/Source/EndlessVendetta/EVGameInstance.cpp
Normal file
32
EndlessVendetta/Source/EndlessVendetta/EVGameInstance.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "EVGameInstance.h"
|
||||||
|
|
||||||
|
void UEVGameInstance::OnStart()
|
||||||
|
{
|
||||||
|
Super::OnStart();
|
||||||
|
GlobalSessionID = FGuid::NewGuid().ToString().Left(5).ToUpper();
|
||||||
|
IsValidSessionID(GlobalSessionID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UEVGameInstance::IsValidSessionID(const FString& SessionID)
|
||||||
|
{
|
||||||
|
const auto Request = FHttpModule::Get().CreateRequest();
|
||||||
|
Request->SetURL("https://ev.api.philipwhite.dev/api/session/" + SessionID);
|
||||||
|
Request->SetVerb("GET");
|
||||||
|
Request->OnProcessRequestComplete().BindUObject(this, &UEVGameInstance::OnResponseReceived);
|
||||||
|
Request->ProcessRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UEVGameInstance::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bConnectedSuccessfully)
|
||||||
|
{
|
||||||
|
if (Response->GetResponseCode() == 200)
|
||||||
|
{
|
||||||
|
GLog->Log("Session ID Exists Regenerating");
|
||||||
|
GlobalSessionID = FGuid::NewGuid().ToString().Left(5).ToUpper();
|
||||||
|
IsValidSessionID(GlobalSessionID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GLog->Log("Session ID is Valid");
|
||||||
|
}
|
28
EndlessVendetta/Source/EndlessVendetta/EVGameInstance.h
Normal file
28
EndlessVendetta/Source/EndlessVendetta/EVGameInstance.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Engine/GameInstance.h"
|
||||||
|
#include "Http.h"
|
||||||
|
#include "EVGameInstance.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class ENDLESSVENDETTA_API UEVGameInstance : public UGameInstance
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry")
|
||||||
|
FString GlobalSessionID = "AAAAA";
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void OnStart() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void IsValidSessionID(const FString& SessionID);
|
||||||
|
void OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bConnectedSuccessfully);
|
||||||
|
};
|
@ -7,7 +7,6 @@
|
|||||||
#include "EnhancedInputComponent.h"
|
#include "EnhancedInputComponent.h"
|
||||||
#include "EnhancedInputSubsystems.h"
|
#include "EnhancedInputSubsystems.h"
|
||||||
#include "InteractionInterface.h"
|
#include "InteractionInterface.h"
|
||||||
#include "Telemetry.h"
|
|
||||||
#include "AI/EnemyCharacter.h"
|
#include "AI/EnemyCharacter.h"
|
||||||
#include "Engine/DamageEvents.h"
|
#include "Engine/DamageEvents.h"
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "EndlessVendettaGameMode.h"
|
#include "EndlessVendettaGameMode.h"
|
||||||
#include "EndlessVendettaCharacter.h"
|
#include "EndlessVendettaCharacter.h"
|
||||||
|
#include "EVGameInstance.h"
|
||||||
#include "UObject/ConstructorHelpers.h"
|
#include "UObject/ConstructorHelpers.h"
|
||||||
#include "EndlessVendetta/AI/EnemyCharacter.h"
|
#include "EndlessVendetta/AI/EnemyCharacter.h"
|
||||||
#include "EndlessVendetta/AI/AIControlHub.h"
|
#include "EndlessVendetta/AI/AIControlHub.h"
|
||||||
@ -60,5 +61,5 @@ void AEndlessVendettaGameMode::SendEvent(FString EventKey, FString EventData)
|
|||||||
void AEndlessVendettaGameMode::BeginPlay()
|
void AEndlessVendettaGameMode::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
SessionID = FGuid::NewGuid().ToString().Left(5).ToUpper();
|
SessionID = Cast<UEVGameInstance>(GetGameInstance())->GlobalSessionID;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
FString TelemetryURLEvents = "https://ev.api.philipwhite.dev/api/event";
|
FString TelemetryURLEvents = "https://ev.api.philipwhite.dev/api/event";
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry")
|
||||||
FString TelemetryURLUsers = "https://ev.api.philipwhite.dev/api/user";
|
FString TelemetryURLUsers = "https://ev.api.philipwhite.dev/api/user";
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Instanced, Category = "Telemetry")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry")
|
||||||
FString SessionID = "AAAAA";
|
FString SessionID = "AAAAA";
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry")
|
||||||
FString PlayerGUID = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
|
FString PlayerGUID = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "Telemetry.h"
|
|
||||||
#include "Misc/Guid.h"
|
|
||||||
|
|
||||||
void ATelemetry::SendEvent(FString EventKey, FString EventData)
|
|
||||||
{
|
|
||||||
const FString EventID = FGuid::NewGuid().ToString();
|
|
||||||
const FString EventTime = FDateTime::Now().ToString();
|
|
||||||
const auto Request = FHttpModule::Get().CreateRequest();
|
|
||||||
Request->SetURL(TelemetryURLEvents);
|
|
||||||
Request->SetVerb("POST");
|
|
||||||
Request->SetHeader("Content-Type", "application/json");
|
|
||||||
Request->SetHeader("Accept", "application/json");
|
|
||||||
Request->SetContentAsString( "{\"SessionID\":\"" + SessionID + "\",\"PlayerGUID\":\"" + PlayerGUID + "\",\"EventID\":\"" + EventID + "\",\"Timestamp\":\"" + EventTime + "\",\"EventKey\":\"" + EventKey + "\",\"EventData\":\"" + EventData + "\"}" );
|
|
||||||
Request->OnProcessRequestComplete().BindLambda([](FHttpRequestPtr request, FHttpResponsePtr response, bool success)
|
|
||||||
{
|
|
||||||
GLog->Log("Telemetry Event Response: " + response->GetContentAsString());
|
|
||||||
});
|
|
||||||
Request->ProcessRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ATelemetry::BeginPlay()
|
|
||||||
{
|
|
||||||
Super::BeginPlay();
|
|
||||||
SessionID = FGuid::NewGuid().ToString().Left(5).ToUpper();
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "GameFramework/GameState.h"
|
|
||||||
#include "Http.h"
|
|
||||||
#include "Telemetry.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class ENDLESSVENDETTA_API ATelemetry : public AGameState
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry")
|
|
||||||
FString TelemetryURLEvents = "https://ev.api.philipwhite.dev/api/event";
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry")
|
|
||||||
FString TelemetryURLUsers = "https://ev.api.philipwhite.dev/api/user";
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry")
|
|
||||||
FString SessionID = "AAAAA";
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Telemetry")
|
|
||||||
FString PlayerGUID = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Telemetry")
|
|
||||||
void SendEvent(FString EventKey, FString EventData);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void BeginPlay() override;
|
|
||||||
};
|
|
@ -7,7 +7,6 @@
|
|||||||
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
||||||
#include "Kismet/KismetMathLibrary.h"
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
#include "Components/CapsuleComponent.h"
|
#include "Components/CapsuleComponent.h"
|
||||||
#include "EndlessVendetta/Telemetry.h"
|
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
#include "Engine/DamageEvents.h"
|
#include "Engine/DamageEvents.h"
|
||||||
#include "EndlessVendetta/AI/EnemyCharacter.h"
|
#include "EndlessVendetta/AI/EnemyCharacter.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user