2022-11-04 13:25:09 +01:00
|
|
|
#ifndef CONNECTION_H
|
|
|
|
#define CONNECTION_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2022-11-06 23:30:21 +01:00
|
|
|
#include "Payload.h"
|
2022-11-04 13:25:09 +01:00
|
|
|
|
|
|
|
class Connection
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
enum class ErrorTypes{
|
|
|
|
none = 0,
|
|
|
|
|
|
|
|
socket_creation = 10,
|
|
|
|
get_ip,
|
|
|
|
connect,
|
2022-11-07 18:53:11 +01:00
|
|
|
|
|
|
|
recv = 20,
|
|
|
|
send
|
2022-11-04 13:25:09 +01:00
|
|
|
}error;
|
|
|
|
|
|
|
|
void p_HandleError();
|
|
|
|
|
|
|
|
public:
|
|
|
|
Connection(std::string server_ip, int port);
|
|
|
|
~Connection();
|
|
|
|
|
2022-11-07 18:53:11 +01:00
|
|
|
bool send(std::vector<Payload> payload, bool size);
|
|
|
|
bool send(Payload payload, bool size);
|
2022-11-06 23:30:21 +01:00
|
|
|
Payload recv();
|
2022-11-04 13:25:09 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the error code from the last command if there is one
|
|
|
|
* @return error_code
|
|
|
|
*/
|
|
|
|
int status();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CONNECTION_H */
|