Skip to content
Snippets Groups Projects
client.hpp 578 B
#ifndef _CLIENT_HPP
#define _CLIENT_HPP

#include <arpa/inet.h>
#include <functional>
#include <string>

#define INPUT_BUFFER_SIZE 1000
class Client {
  int sock;
  sockaddr_in serverAddr;
  char inputBuffer[INPUT_BUFFER_SIZE];

  typedef std::function<void(uint16_t, char *)> receiveCallbackType;

public:
  Client();
  Client(const std::string &serverAddr, const int &port);

  void disconnect();
  uint16_t sendMessage(const char *);
  void receiveMessage();

  void onInput(receiveCallbackType cb);

private:
  receiveCallbackType receiveCallback;
};
#endif // !_CLIENT_HPP