Migrate core infrastructure to VoidLibrary

This commit is contained in:
faumaray committed 2026-06-22 15:53:23 +03:00
1 parent 53801f2b53
commit 2bdb63766d
65 files changed
+16109 -12011

No files matched your search

+60 -51
View File
@@ -1,64 +1,73 @@
#pragma once
#include <echoion/api.hpp>
#include "Database.hpp"
#include <TrackTypes.hpp>
#include <Types.hpp>
#include <memory>
#include <mutex>
#include <set>
#include <string>
#include <mutex>
#include <memory>
#include <vector>
namespace Echoion::Core {
namespace Echoion::Core
{
/**
* Manages user subscriptions to the bot's audio output
* Subscriptions are persisted to database and survive client reloads
* Uses unique client UID instead of session-specific client ID
*/
class SubscriptionManager {
public:
struct Subscriber {
std::string uid;
std::string nickname;
};
/**
* Manages user subscriptions to the bot's audio output
* Subscriptions are persisted to database and survive client reloads
* Uses unique client UID instead of session-specific client ID
*/
class SubscriptionManager
{
public:
SubscriptionManager();
~SubscriptionManager();
struct Subscriber {
std::string uid;
std::string nickname;
};
// Initialize and load subscriptions from database
Api::Result<void> initialize(std::shared_ptr<Api::Database> database);
void shutdown();
SubscriptionManager();
~SubscriptionManager();
// Subscription management (by UID)
bool subscribe(const std::string& uid, const std::string& nickname);
bool unsubscribe(const std::string& uid);
bool isSubscribed(const std::string& uid) const;
// Get all subscribed UIDs
std::vector<std::string> getSubscribedUids() const;
// Get all subscribers with info
std::vector<Subscriber> getSubscribers() const;
// Get subscriber nickname
std::optional<std::string> getSubscriberNickname(const std::string& uid) const;
// Update nickname for subscriber
bool updateNickname(const std::string& uid, const std::string& nickname);
// Check if anyone is subscribed
bool hasSubscribers() const;
// Get subscriber count
size_t getSubscriberCount() const;
// Clear all subscriptions
bool clearAll();
// Initialize and load subscriptions from database
Api::Result<void>
initialize(std::shared_ptr<Api::Database> database);
void shutdown();
private:
std::set<std::string> subscribedUids_;
mutable std::mutex mutex_;
std::shared_ptr<Api::Database> database_;
bool initialized_ = false;
};
// Subscription management (by UID)
bool subscribe(const std::string& uid, const std::string& nickname);
bool unsubscribe(const std::string& uid);
bool isSubscribed(const std::string& uid) const;
// Get all subscribed UIDs
std::vector<std::string> getSubscribedUids() const;
// Get all subscribers with info
std::vector<Subscriber> getSubscribers() const;
// Get subscriber nickname
std::optional<std::string>
getSubscriberNickname(const std::string& uid) const;
// Update nickname for subscriber
bool updateNickname(const std::string& uid,
const std::string& nickname);
// Check if anyone is subscribed
bool hasSubscribers() const;
// Get subscriber count
size_t getSubscriberCount() const;
// Clear all subscriptions
bool clearAll();
private:
std::set<std::string> subscribedUids_;
mutable std::mutex mutex_;
std::shared_ptr<Api::Database> database_;
bool initialized_ = false;
};
} // namespace Echoion::Core