Documentation for the Unreal C++ Plugin
Loading...
Searching...
No Matches
ApexSDKLibrary.cpp
Go to the documentation of this file.
1// Copyright 2022 PixoVR Corp. All Rights Reserved.
2
3#include "ApexSDKLibrary.h"
4#include "ApexAPI.h"
5#include "Interfaces/IPluginManager.h"
6
7#if WITH_EDITOR
8#include "Editor/EditorEngine.h"
9#endif
10
11bool UApexSDKLibrary::GetCurrentSessionGuid(UObject* WorldContextObject, FGuid& OutCurrentSessionId)
12{
13 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
14 if (Subsystem != nullptr)
15 {
16 OutCurrentSessionId = Subsystem->CurrentSessionGuid;
17 return true;
18 }
19
20 return false;
21}
22
23FString UApexSDKLibrary::GetClientIP(UObject* WorldContextObject)
24{
25 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
26 if (Subsystem != nullptr)
27 {
28 return Subsystem->ClientIP;
29 }
30
31 return TEXT("");
32}
33
34FString UApexSDKLibrary::GetDeviceModel(UObject* WorldContextObject)
35{
36 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
37 if (Subsystem != nullptr)
38 {
39 return Subsystem->DeviceModel;
40 }
41
42 return TEXT("");
43}
44
45FString UApexSDKLibrary::GetDeviceId(UObject* WorldContextObject)
46{
47 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
48 if (Subsystem != nullptr)
49 {
50 return Subsystem->DeviceId;
51 }
52
53 return TEXT("");
54}
55
56FString UApexSDKLibrary::GetPlatform(UObject* WorldContextObject)
57{
58 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
59 if (Subsystem != nullptr)
60 {
61 return Subsystem->Platform;
62 }
63
64 return TEXT("");
65}
66
67int UApexSDKLibrary::GetModuleId(UObject* WorldContextObject)
68{
69 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
70 if (Subsystem != nullptr)
71 {
72 return Subsystem->LoadedModuleId;
73 }
74
75 return -1;
76}
77
78FString UApexSDKLibrary::GetModuleVersion(UObject* WorldContextObject)
79{
80 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
81 if (Subsystem != nullptr)
82 {
83 return Subsystem->ModuleVersion;
84 }
85
86 return TEXT("");
87}
88
89
90bool UApexSDKLibrary::GetCurrentUser(UObject* WorldContextObject, FUserSessionData& OutUser)
91{
92 bool bIsLoggedIn = false;
93
94 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
95 if (Subsystem != nullptr)
96 {
97 bIsLoggedIn = Subsystem->IsLoggedIn();
98 if (bIsLoggedIn)
99 {
100 OutUser = Subsystem->CurrentActiveLogin;
101 }
102 }
103
104 return bIsLoggedIn;
105}
106
108{
109 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
110 if (Subsystem != nullptr)
111 {
112 return Subsystem->IsLoggedIn();
113 }
114
115 return false;
116}
117
119{
120 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
121 if (Subsystem != nullptr)
122 {
123 return Subsystem->bSessionInProgress;
124 }
125
126 return false;
127}
128
129FString UApexSDKLibrary::GetAuthToken(UObject* WorldContextObject)
130{
131 UApexAPI* Subsystem = GetApexAPI(WorldContextObject);
132 if (Subsystem != nullptr)
133 {
134 if (Subsystem->IsLoggedIn())
135 {
136 return Subsystem->CurrentActiveLogin.SessionToken;
137 }
138 }
139
140 return TEXT("");
141}
142
144{
145 UWorld* World = WorldContextObject->GetWorld();
146
147 check(World);
148 UGameInstance* GameInstance = World->GetGameInstance();
149
150 check(GameInstance);
151
152 return GameInstance->GetSubsystem<UApexAPI>();
153}
UCLASS(BlueprintType, Blueprintable)
Definition ApexAPI.h:76
bool IsLoggedIn()
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API")
Definition ApexAPI.cpp:431
FString Platform
UPROPERTY(BlueprintReadOnly)
Definition ApexAPI.h:128
FString ClientIP
UPROPERTY(BlueprintReadOnly)
Definition ApexAPI.h:146
FGuid CurrentSessionGuid
UPROPERTY(BlueprintReadOnly)
Definition ApexAPI.h:152
FString ModuleVersion
UPROPERTY(BlueprintReadOnly)
Definition ApexAPI.h:122
FUserSessionData CurrentActiveLogin
UPROPERTY(BlueprintReadOnly)
Definition ApexAPI.h:158
FString DeviceModel
UPROPERTY(BlueprintReadOnly)
Definition ApexAPI.h:140
int LoadedModuleId
UPROPERTY(BlueprintReadWrite, Meta=(DisplayName="Module Id"))
Definition ApexAPI.h:116
FString DeviceId
UPROPERTY(BlueprintReadOnly)
Definition ApexAPI.h:134
bool bSessionInProgress
UPROPERTY(BlueprintReadOnly)
Definition ApexAPI.h:168
static bool IsSessionInProgress(UObject *WorldContextObject)
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API", meta=(WorldContext = "WorldContext...
static bool GetCurrentUser(UObject *WorldContextObject, FUserSessionData &OutUser)
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API", meta=(WorldContext = "WorldContext...
static FString GetDeviceId(UObject *WorldContextObject)
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API", meta = (WorldContext = "WorldConte...
static FString GetDeviceModel(UObject *WorldContextObject)
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API", meta = (WorldContext = "WorldConte...
static FString GetPlatform(UObject *WorldContextObject)
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API", meta = (WorldContext = "WorldConte...
static class UApexAPI * GetApexAPI(UObject *WorldContextObject)
static FString GetClientIP(UObject *WorldContextObject)
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API", meta = (WorldContext = "WorldConte...
static int GetModuleId(UObject *WorldContextObject)
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API", meta=(WorldContext = "WorldContext...
static bool IsUserLoggedIn(UObject *WorldContextObject)
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API", meta=(WorldContext = "WorldContext...
static FString GetAuthToken(UObject *WorldContextObject)
static bool GetCurrentSessionGuid(UObject *WorldContextObject, FGuid &OutCurrentSessionId)
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API", meta = (WorldContext = "WorldConte...
static FString GetModuleVersion(UObject *WorldContextObject)
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Apex|API", meta=(WorldContext = "WorldContext...
USTRUCT(BlueprintType)
Definition ApexTypes.h:536
FString SessionToken
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|User Session Data")
Definition ApexTypes.h:580