mcping/Connection.h
2022-11-09 17:49:55 +01:00

42 lines
619 B
C++

#ifndef CONNECTION_H
#define CONNECTION_H
#include <string>
#include <vector>
#include "Payload.h"
class Connection
{
private:
int fd;
enum class ErrorTypes{
none = 0,
socket_creation = 10,
get_ip,
connect,
recv = 20,
send
}error = ErrorTypes::none;
void p_HandleError();
public:
Connection(std::string server_ip, int port);
~Connection();
bool send(std::vector<Payload> payload, bool size);
bool send(Payload payload, bool size);
Payload recv();
/**
* Return the error code from the last command if there is one
* @return error_code
*/
int status();
};
#endif /* CONNECTION_H */