#pragma once #include "MessageBoard.hpp" #include "Chatbar.hpp" #include "User.hpp" #include "Channel.hpp" #include #include #include namespace odhtdb { class Database; } namespace dchat { class Channel { public: Channel(const std::string &name, const odhtdb::DatabaseNode &databaseNodeInfo = odhtdb::DatabaseNode(), User *localUser = nullptr, odhtdb::Database *database = nullptr); virtual ~Channel(); User* getLocalUser(); MessageBoard& getMessageBoard(); const std::string& getName() const; const std::vector getUsers() const; User* getUserByPublicKey(const odhtdb::Signature::PublicKey &publicKey); // If timestamp is 0, then timestamp is not used void addLocalMessage(const std::string &msg, User *owner, u64 timestampSeconds = 0); void addMessage(const std::string &msg); void addUser(User *user); void processEvent(const sf::Event &event); void draw(sf::RenderWindow &window, Cache &cache); static void setCurrent(Channel *channel); static Channel* getCurrent(); protected: odhtdb::Database *database; odhtdb::DatabaseNode databaseNodeInfo; std::string name; MessageBoard messageBoard; Chatbar chatbar; User *localUser; SystemUser systemUser; std::vector users; odhtdb::Signature::MapPublicKey publicKeyOnlineUsersMap; }; }