diff --git a/include/neocomm/channel.hpp b/include/neocomm/channel.hpp index 1d97269..40f8c5c 100644 --- a/include/neocomm/channel.hpp +++ b/include/neocomm/channel.hpp @@ -28,18 +28,24 @@ namespace neocomm { class channel { public: + /** + * @brief Initialize a channel object (this should pretty + * much only be done by the node object). + * + * @param name Name of the channel. + * @param network A pointer to the OpenDHT node. + */ channel(const std::string &name, dht::DhtRunner *network); ~channel(); + /** + * @brief Get the name of the channel. + * + * @return The name of the channel. + */ inline std::string get_name() const { return name; } - //inline dht::InfoHash get_key() const { - //return key; - //} - //inline size_t get_token() { - //return token.get(); - //} private: const std::string name; diff --git a/include/neocomm/node.hpp b/include/neocomm/node.hpp index fc422dd..1214626 100644 --- a/include/neocomm/node.hpp +++ b/include/neocomm/node.hpp @@ -64,9 +64,45 @@ public: */ void export_nodes(const std::string &file_path); // TODO + /** + * @brief Join a channel. + * + * @param name Name of the channel. + * + * @note If the channel is already joined on this node + * then it does nothing and returns a nullptr. + * + * @return Returns a pointer to the channel object. + */ channel *join_channel(const std::string &name); + /** + * @brief Get a pointer to a channel object by name. + * + * @param name The name of the channel. + * + * @note If the channel has not been joined on this node + * then it returns nullptr. + * + * @return A pointer to the channel object. + */ channel *get_channel(const std::string &name); + /** + * @brief Leave a channel by name. + * + * @note If the channel has not been joined on this node + * it does nothing. + * + * @param name The name of the channel. + */ void leave_channel(const std::string &name); + /** + * @brief Leave a channel by pointer to the object. + * + * @note If the channel has not been joined on this node + * it does nothing. + * + * @param chan The channel object. + */ inline void leave_channel(channel *chan) { leave_channel(chan->get_name()); }