5#include "CoreMinimal.h"
6#include "UObject/NoExportTypes.h"
7#include "nakama-cpp/Nakama.h"
8#include "NakamaManager.generated.h"
17#define SYSTEM_USER std::string("00000000-0000-0000-0000-000000000000")
18#define STATS_COLLECTION std::string("stats");
19#define AUTHORITATIVE_STATS_COLLECTION std::string("stats_authoritative");
20#define LOAD_STAT_FUNCTION std::string("listLeaderboardStatEntries")
21#define SAVE_STAT_FUNCTION std::string("authenticatedUpdateStats")
22#define UPDATE_LEADERBOARD_FUNCTION std::string("authenticatedUpdateLeaderboard")
23#define SAVE_EXPERIENCE_FUNCTION std::string("updateExperienceRPC")
24#define LOAD_STORE_FUNCTION std::string("loadActiveStore")
25#define PLAYER_INVENTORY std::string("Inventory")
26#define SERVER_HISTORY std::string("ServerHistory")
27#define INITIALIZE_INVENTORY_FUNCTION std::string("initializePlayerInventory")
28#define PLAYER_EQUIPS_SAVE_FUNCTION std::string("savePlayerEquips")
29#define FETCH_ID_FROM_STEAM_ID std::string("getAccountBySteamId")
30#define FETCH_IDS_FROM_STEAM_IDS std::string("getAccountsBySteamIds")
31#define PURCHASE_STORE_ITEM std::string("purchaseStoreItem")
32#define EQUIP_REQUEST std::string("getPlayerEquips")
33#define LOAD_CHALLENGE_FUNCTION std::string("loadChallenges")
34#define LOAD_LEADERBOARD_FUNCTION std::string("loadLeaderboardEntriesForStat")
35#define REROLL_CHALLENGE_FUNCTION std::string("rerollChallenge")
36#define FREEREROLL_CHALLENGE_FUNCTION std::string("freeReroll")
37#define CLAIM_CHALLENGE_FUNCTION std::string("claimChallenge")
38#define UPDATE_CHALLENGE_FUNCTION std::string("updateChallengeProgress")
39#define SERVER_ITEM_UNLOCK_FUNCTION std::string("authenticatedWriteStorageObjects")
40#define GET_TWITCH_REWARDS std::string("awardTwitchDrops")
41#define VERIFY_TWITCH_INTEGRATION std::string("checkTwitchAccountLinked")
42#define REDEEM_REFERAFRIEND std::string("redeemReferral")
43#define CONSUME_MATCH_BONUS std::string("consumeMatchBonus")
44#define CONSUME_LOGIN_BONUS std::string("consumeLogInBonus")
45#define CHECK_LOGIN_BONUS std::string("checkLoginBonus")
46#define UNLINK_TWITCH_INTEGRATION std::string("unlinkTwitchAccount")
47#define UNLOCK_FOUNDERSPACK_FUNCTION std::string("unlockFoundersPackItemsSteam")
48#define CONSUME_ITEM_FUNCTION std::string("consumeItem")
49#define SESSION_LOCK_ITEM_FUNCTION std::string("saveSessionLockedCosmetics")
50#define REWARD_COLLECTION std::string("rewards")
51#define DAILY_COLLECTION std::string("dailyTimer")
53UCLASS(config =
"Game")
59 UFUNCTION(BlueprintCallable, Category = NakamaHelper)
61 UFUNCTION(BlueprintCallable,BlueprintPure)
62 static bool IsAvailable(UObject*
const WorldContextObject);
63 UFUNCTION(BlueprintCallable)
64 static void Reconnect(UObject*
const WorldContextObject);
65 static NAKAMA_NAMESPACE::NClientPtr GetClient(UObject*
const WorldContextObject);
66 static NAKAMA_NAMESPACE::NSessionPtr GetSession(UObject*
const WorldContextObject);
68 void Init(
bool bDedicatedServer, UGameInstance*
const WorldContextObject);
70 bool Tick(
float DeltaSeconds);
71 bool GetAuthToken(FString& EncodedAuthToken);
72 void Authenticate(FString AuthToken,
bool bReAuthenticationAttempt =
false);
74 void AuthenticationResponse(NAKAMA_NAMESPACE::NSessionPtr session,
bool bReAuthentication);
75 static void AsyncFetchUserAccount(
const TArray<FString>& NakamaIDs, UObject*
const WorldContextObject, FUserIdFetchDelegate Callback);
77 UFUNCTION(BlueprintPure, meta = (WorldContext =
"WorldContextObject"))
78 static FString GetNakamaUserId(UObject*
const WorldContextObject);
79 UPROPERTY(BlueprintAssignable, Category = NakamaHelper)
80 FNakamaConnectedSignature OnNakamaConnected;
81 UPROPERTY(BlueprintAssignable, Category = NakamaHelper)
82 FNakamaFailedConnectionSignature OnNakamaFailedConnection;
84 FString SecretKey = "12345678";
88 NAKAMA_NAMESPACE::NClientPtr NakamaClient =
nullptr;
89 NAKAMA_NAMESPACE::NSessionPtr NakamaSession =
nullptr;
91 std::
string NakamaAuthToken;
92 bool bLocalPlayerInitialized = false;
93 bool bIsDedicatedServer = false;
94 bool bFailedReAuthentication = false;
95 bool bFirstRun = true;
DECLARE_DELEGATE_OneParam(FUserIdFetchDelegate, const std::vector< NAKAMA_NAMESPACE::NUser > &)
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FNakamaConnectedSignature)
Definition: NakamaManager.h:55