2024-04-23 02:27:08 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
#include <any>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <string>
|
|
|
|
|
2024-06-11 17:17:45 +02:00
|
|
|
#include "../helpers/memory/Memory.hpp"
|
2024-05-05 18:16:00 +02:00
|
|
|
|
2024-04-23 02:27:08 +02:00
|
|
|
class CUUIDToken {
|
|
|
|
public:
|
2024-06-25 16:05:39 +02:00
|
|
|
CUUIDToken(const std::string& uuid_, std::any data_, std::chrono::steady_clock::duration expires);
|
2024-04-23 02:27:08 +02:00
|
|
|
|
|
|
|
std::string getUUID();
|
|
|
|
|
|
|
|
std::any data;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string uuid;
|
|
|
|
|
2024-06-25 16:05:39 +02:00
|
|
|
std::chrono::steady_clock::time_point expiresAt;
|
2024-04-23 02:27:08 +02:00
|
|
|
|
|
|
|
friend class CTokenManager;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CTokenManager {
|
|
|
|
public:
|
2024-06-25 16:05:39 +02:00
|
|
|
std::string registerNewToken(std::any data, std::chrono::steady_clock::duration expires);
|
2024-05-05 18:16:00 +02:00
|
|
|
std::string getRandomUUID();
|
2024-04-23 02:27:08 +02:00
|
|
|
|
2024-05-05 18:16:00 +02:00
|
|
|
SP<CUUIDToken> getToken(const std::string& uuid);
|
|
|
|
void removeToken(SP<CUUIDToken> token);
|
2024-04-23 02:27:08 +02:00
|
|
|
|
|
|
|
private:
|
2024-05-05 18:16:00 +02:00
|
|
|
std::unordered_map<std::string, SP<CUUIDToken>> m_mTokens;
|
2024-04-23 02:27:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline std::unique_ptr<CTokenManager> g_pTokenManager;
|