46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <echoion/api.hpp>
|
|
#include <set>
|
|
#include <string>
|
|
#include <mutex>
|
|
#include <memory>
|
|
|
|
namespace Echoion::Core {
|
|
|
|
/**
|
|
* Manages user subscriptions to the bot's audio output
|
|
* Subscriptions are persisted to database and survive client reloads
|
|
*/
|
|
class SubscriptionManager {
|
|
public:
|
|
SubscriptionManager();
|
|
~SubscriptionManager();
|
|
|
|
// Initialize and load subscriptions from database
|
|
Api::Result<void> initialize(std::shared_ptr<Api::Database> database);
|
|
void shutdown();
|
|
|
|
// Subscription management
|
|
bool subscribe(uint64_t clientId);
|
|
bool unsubscribe(uint64_t clientId);
|
|
bool isSubscribed(uint64_t clientId) const;
|
|
|
|
// Get all subscribed clients
|
|
std::set<uint64_t> getSubscribedClients() const;
|
|
|
|
// Check if anyone is subscribed
|
|
bool hasSubscribers() const;
|
|
|
|
// Get subscriber count
|
|
size_t getSubscriberCount() const;
|
|
|
|
private:
|
|
std::set<uint64_t> subscribedClients_;
|
|
mutable std::mutex mutex_;
|
|
std::shared_ptr<Api::Database> database_;
|
|
bool initialized_ = false;
|
|
};
|
|
|
|
} // namespace Echoion::Core
|