diff --git a/include/neocomm.h b/include/neocomm.h index 9fcb60c..e1f622e 100644 --- a/include/neocomm.h +++ b/include/neocomm.h @@ -20,8 +20,26 @@ #ifdef __cplusplus extern "C" { +#include +#else +#include #endif +/** + * @brief A structure with necessary variables for other users. + */ +struct user { + const char *nick; ///< The alias used by the user. + const char *hash; ///< The unique hash of the user. +}; + +struct message { + const char *msg; ///< The text message. + time_t sent; ///< The time it was sent. + time_t received; ///< The time it was received. + struct user peer; ///< Info on the peer who sent the message. +}; + /** * @brief Initialize a local DHT node. If port is 0 then the default port * number will be used. @@ -36,7 +54,7 @@ void NeoComm_init(unsigned short port); void NeoComm_deinit(); /** - * @brief A foreign node to connect to. + * @brief Connect to a foreign node. * * @param address DNS/IP of the node. * @param port Port of the foreign node. @@ -83,6 +101,21 @@ int NeoComm_join_channel(const char *channel_name); */ void NeoComm_leave_channel(const char *channel_name); +/** + * @brief Get the next available message (in chronological order) for + * a given channel. + * + * @param channel_name Channel to check for new messages. + * + * @return A structure of the message. If NULL then there are no new messages. + * + * @warn This command will remove the message from the internal list. + * @warn The message must be freed from memory using NeoComm_free_message. + */ +struct message *NeoComm_get_next_message(const char *channel_name); + +void NeoComm_free_message(struct message *msg); + /** * @brief Get the last error that occurred in text. *