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); +}