mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-05-05 04:49:36 +01:00
applied platformio structure
This commit is contained in:
40
lib/spotify/cspot/include/AccessKeyFetcher.h
Normal file
40
lib/spotify/cspot/include/AccessKeyFetcher.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic> // or std::atomic
|
||||
#include <functional> // for function
|
||||
#include <memory> // for shared_ptr
|
||||
#include <string> // for string
|
||||
|
||||
namespace cspot {
|
||||
struct Context;
|
||||
|
||||
class AccessKeyFetcher {
|
||||
public:
|
||||
AccessKeyFetcher(std::shared_ptr<cspot::Context> ctx);
|
||||
|
||||
/**
|
||||
* @brief Checks if key is expired
|
||||
* @returns true when currently held access key is not valid
|
||||
*/
|
||||
bool isExpired();
|
||||
|
||||
/**
|
||||
* @brief Fetches a new access key
|
||||
* @remark In case the key is expired, this function blocks until a refresh is done.
|
||||
* @returns access key
|
||||
*/
|
||||
std::string getAccessKey();
|
||||
|
||||
/**
|
||||
* @brief Forces a refresh of the access key
|
||||
*/
|
||||
void updateAccessKey();
|
||||
|
||||
private:
|
||||
std::shared_ptr<cspot::Context> ctx;
|
||||
|
||||
std::atomic<bool> keyPending = false;
|
||||
std::string accessKey;
|
||||
long long int expiresAt;
|
||||
};
|
||||
} // namespace cspot
|
||||
Reference in New Issue
Block a user