#ifndef BLITE_CLIENT_H
#define BLITE_CLIENT_H

#include "bibun_lite/message.h"

#include <stdlib.h>

namespace blite
{

class Client
{
public:
   Client(const char *application_name,
          int node_channeler_port,
          int node_broadcaster_port,
          const char *subscriptions[],
          size_t subscriptions_length
   );

   // Send a message. 0 means success. Negative number means failed. This function does not block.
   int send(char *buffer,           // Your buffer, probably won't be edited.
      size_t length,                // The length of the buffer in bytes, you don't need to null-terminate.
      int valid_for_seconds = 60,   // Duration the message makes sense for.
      const char *optional_type = 0, // Description of what is contained in buffer. Optional if there is one encoding.
      void (*buffer_deleter)(char *) = 0 // If you don't use malloc, give me a function pointer for freeing your buffer.
   );

   // Check if we have any messages. Return is null if we do not... remember to delete the message with
   // "delete msg_ptr;".
   Message *receive();

   ~Client();
private:
   void *_resources;
   void *_worker;
};

}

#endif // BLITE_CLIENT_H
