Created message handling functions.

This commit is contained in:
Nicolás Ortega Froysa 2017-09-23 11:30:02 +02:00
parent d5a33ccd79
commit bcb01f256d
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF

View File

@ -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<struct message*>(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);
}