many different fixes
This commit is contained in:
1 parent
a583c17916
commit
53801f2b53
36 files changed
+5149
-1291
No files matched your search
@@ -5,15 +5,22 @@
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
SubscriptionManager();
|
||||
~SubscriptionManager();
|
||||
|
||||
@@ -21,22 +28,34 @@ public:
|
||||
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;
|
||||
// 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 clients
|
||||
std::set<uint64_t> getSubscribedClients() 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<uint64_t> subscribedClients_;
|
||||
std::set<std::string> subscribedUids_;
|
||||
mutable std::mutex mutex_;
|
||||
std::shared_ptr<Api::Database> database_;
|
||||
bool initialized_ = false;
|
||||
|
||||
Reference in new issue
Block a user