From bcb01f256d8e3ac7fccc24b6a99c0e458d58de90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Sat, 23 Sep 2017 11:30:02 +0200 Subject: [PATCH] Created message handling functions. --- src/channel.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/channel.cpp b/src/channel.cpp index 21281bf..cf12ebc 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -73,3 +73,21 @@ void NeoComm_leave_channel(const char *channel_name) { node.cancelListen(channel->hash, channel->token.get()); channels.erase(s_chan_name); } + +struct message *NeoComm_get_next_message(const char *channel_name) { + const std::string s_chan_name(channel_name); + if(channels[s_chan_name].msgs.empty()) + return NULL; + const dht::ImMessage *new_msg = &channels[s_chan_name].msgs.front(); + struct message *msg = + static_cast(malloc(sizeof(struct message))); + + msg->msg = new_msg->msg.c_str(); + // TODO: add the rest of these + + return msg; +} + +void NeoComm_free_message(struct message *msg) { + free(msg); +}