LootLocker Unreal SDK 10.4.0
Game backend SDK for Unreal Engine
Loading...
Searching...
No Matches
LootLockerHTTPExecutionQueue.h
Go to the documentation of this file.
1// Copyright (c) 2021 LootLocker
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Containers/Ticker.h"
7#include "Runtime/Launch/Resources/Version.h"
11
13
31class LOOTLOCKERSDK_API FLootLockerHTTPExecutionQueue
32{
33public:
34 // -------------------------------------------------------------------------
35 // Singleton lifecycle
36 // -------------------------------------------------------------------------
37
40
42 static void Initialize();
43
45 static bool IsInitialized();
46
51 static void Shutdown();
52
53 // -------------------------------------------------------------------------
54 // Public API
55 // -------------------------------------------------------------------------
56
66
69
72
73private:
74 static TUniquePtr<FLootLockerHTTPExecutionQueue> Instance;
75
76 bool bIsInitialized = false;
78 TUniquePtr<FLootLockerRateLimiter> RateLimiter;
79
81 TMap<FString, TSharedPtr<FLootLockerHTTPExecutionQueueItem>> ExecutionQueue;
82
84 TSet<FString> OngoingRequestIds;
85
90 TArray<FString> CompletedRequestIds;
91
93 TArray<FString> RefreshNeededIds;
94
95 // --- SDK identity headers (mirrors ULootLockerHttpClient statics) ---
96 static FString SDKVersion;
97 static const FString UserAgent;
98 static const FString UserInstanceIdentifier;
99
100 // --- Per-tick helpers ---
101
107 bool CreateAndSendRequest(FLootLockerHTTPExecutionQueueItem& Item);
108
115
120 void HandleRequestResult(
123
129 void DispatchSessionRefreshForItem(const FString& RequestId);
130
139 void OnSessionRefreshCompleted(const FString& RequestId, bool bRefreshSuccess);
140
146 void MarkItemDone(FLootLockerHTTPExecutionQueueItem& Item, const FLootLockerResponse& Response);
147
164 void CompleteItem(FLootLockerHTTPExecutionQueueItem& Item, const FLootLockerResponse& Response);
165
170 bool ShouldRetryRequest(int32 StatusCode, int32 TimesRetried) const;
171
176 bool ShouldRefreshSession(int32 StatusCode, const FLootLockerPlayerData& PlayerData,
177 int32 TimesRetried) const;
178
181 double LastChokeWarningLogTime = 0.0;
182
183 // --- Ticker ---
184
186#if ENGINE_MAJOR_VERSION > 5 || (ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 3)
187 FTSTicker::FDelegateHandle TickerHandle;
188#else
189 FDelegateHandle TickerHandle;
190#endif
191
193 void StartTicker();
194
196 void StopTicker();
197
202 bool Tick(float DeltaTime);
203};
ELootLockerHTTPExecutionQueueProcessingResult
Outcome codes returned by the HTTP execution queue's per-tick processing loop.
Definition LootLockerHTTPExecutionQueueItem.h:15
Manages the LootLocker HTTP request queue as a per-frame singleton.
Definition LootLockerHTTPExecutionQueue.h:32
static void Shutdown()
Aborts all in-flight requests, drains the queue with error callbacks, and destroys the singleton.
FLootLockerHTTPExecutionQueue()=default
Do not construct directly — use Get() or Initialize() instead.
void OverrideConfiguration(const FLootLockerHTTPClientConfiguration &NewConfig)
Replaces the active configuration.
static void Initialize()
Creates and starts ticking the singleton.
static bool IsInitialized()
Returns true if Initialize() has been called and Shutdown() has not yet been called.
void ScheduleRequest(const FLootLockerHTTPRequestData &Request)
Enqueues a request for dispatch on the next available tick.
static FLootLockerHTTPExecutionQueue & Get()
Returns the singleton instance.
Configuration for the LootLocker HTTP execution queue and retry logic.
Definition LootLockerHTTPClientConfiguration.h:15
Pairs a pending FLootLockerHTTPRequestData with its active IHttpRequest handle.
Definition LootLockerHTTPExecutionQueueItem.h:55
Captures everything needed to dispatch — and later retry — a single SDK HTTP request.
Definition LootLockerHTTPRequestData.h:15
Definition LootLockerPlayerData.h:12
Base response struct — every SDK callback receives a struct that derives from this.
Definition LootLockerResponse.h:19