New structs, and functions to implements.
This commit is contained in:
parent
43772c6181
commit
d7f4a7f475
@ -20,8 +20,26 @@
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#include <ctime>
|
||||||
|
#else
|
||||||
|
#include <time.h>
|
||||||
#endif
|
#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
|
* @brief Initialize a local DHT node. If port is 0 then the default port
|
||||||
* number will be used.
|
* number will be used.
|
||||||
@ -36,7 +54,7 @@ void NeoComm_init(unsigned short port);
|
|||||||
void NeoComm_deinit();
|
void NeoComm_deinit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A foreign node to connect to.
|
* @brief Connect to a foreign node.
|
||||||
*
|
*
|
||||||
* @param address DNS/IP of the node.
|
* @param address DNS/IP of the node.
|
||||||
* @param port Port of the foreign 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);
|
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.
|
* @brief Get the last error that occurred in text.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user