New structs, and functions to implements.

This commit is contained in:
Nicolás Ortega Froysa 2017-09-22 08:41:52 +02:00
parent 43772c6181
commit d7f4a7f475
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF

View File

@ -20,8 +20,26 @@
#ifdef __cplusplus
extern "C" {
#include <ctime>
#else
#include <time.h>
#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.
*