Check status of sent messages.

This commit is contained in:
Nicolás Ortega Froysa
2017-09-25 17:19:16 +02:00
parent 763277dd9b
commit 59d59549e1
2 changed files with 50 additions and 10 deletions

View File

@ -47,6 +47,15 @@ struct message {
struct user from; ///< Info on the peer who sent the message.
};
/**
* @brief Status of a message.
*/
enum {
NC_PENDING = 1, ///< Status of message is pending.
NC_GOOD = 2, ///< Message was sent properly.
NC_BAD = 3, ///< Message failed to send.
};
/**
* @brief Initialize a local DHT node. If port is 0 then the default port
* number will be used.
@ -137,10 +146,23 @@ void NeoComm_free_message(struct message *msg);
* @param channel_name Name of the channel to send the message to.
* @param message A message to send to the channel.
*
* @return 1 upon success, 0 upon failure. Use NeoComm_get_last_error for a
* text description of the error.
* @return Upon success it returns the time that the message was sent which
* can be used as a token to see if the message was sent properly using
* NeoComm_check_message, if the function failed then 0 will be returned.
*/
int NeoComm_send_message(const char *channel_name, const char *message);
time_t NeoComm_send_message(const char *channel_name, const char *message);
/**
* @brief Check the status of a sent message.
*
* @param token The token of a message to check its status.
*
* @return The status of the message (NC_GOOD, NC_BAD, or NC_PENDING). If the
* token does not exist then 0 is returned.
*
* @warning Once checked the token becomes invalid.
*/
int NeoComm_check_message(const time_t token);
/**
* @brief Get the last error that occurred in text.