My Project
IUdpCommunication.hpp
1 /*
2 ** EPITECH PROJECT, 2022
3 ** B-CPP-500-PAR-5-1-rtype-martin.vanaud
4 ** File description:
5 ** IUdpCommunication
6 */
7 
8 #ifndef IUDPCOMMUNICATION_HPP_
9  #define IUDPCOMMUNICATION_HPP_
10 
11  #include <functional>
12  #include <utility>
13 
14  #include <asio/ip/udp.hpp>
15  #include <asio/error_code.hpp>
16  #include <asio/io_context.hpp>
17 
18 using byte = unsigned char;
19 
24  public:
25 
29  virtual ~IUdpCommunication() = default;
30 
36  virtual void send(std::vector<byte> const &data) = 0;
37 
45  virtual void send(std::vector<byte> const &data, asio::ip::address const &address, unsigned short const &port) = 0;
46 
53  virtual void async_send(std::vector<byte> const &data, std::function<void(std::error_code const &, std::size_t)> callBack) = 0;
54 
63  virtual void async_send(std::vector<byte> const &data, std::function<void(std::error_code const &, std::size_t)> callBack, asio::ip::address const &address, unsigned short const &port) = 0;
64 
71  virtual std::pair<asio::ip::address, unsigned short> receive(std::vector<byte> &data) = 0;
72 
79  virtual void async_receive(std::vector<byte> &data, std::function<void(std::error_code const &, std::size_t)> callBack) = 0;
80 
86  virtual std::pair<asio::ip::address, unsigned short> getEnpointInfo() const = 0;
87 
93  virtual void setEnpointInfo(std::pair<asio::ip::address, unsigned short> const &endpointInfo) = 0;
94 
101  virtual void setEnpointInfo(asio::ip::address const &address, unsigned short const &port) = 0;
102 
103  protected:
104  private:
105 };
106 
107 #endif /* !IUDPCOMMUNICATION_HPP_ */
IUdpCommunication::async_receive
virtual void async_receive(std::vector< byte > &data, std::function< void(std::error_code const &, std::size_t)> callBack)=0
A method to receive a message in an async way.
IUdpCommunication::getEnpointInfo
virtual std::pair< asio::ip::address, unsigned short > getEnpointInfo() const =0
Get the Enpoint Info object.
IUdpCommunication::setEnpointInfo
virtual void setEnpointInfo(std::pair< asio::ip::address, unsigned short > const &endpointInfo)=0
Set the Enpoint Info object.
IUdpCommunication::async_send
virtual void async_send(std::vector< byte > const &data, std::function< void(std::error_code const &, std::size_t)> callBack)=0
A method to send a message to an already known ip adress and port adress in an async way.
IUdpCommunication
Interface representing UdpCommunication.
Definition: IUdpCommunication.hpp:23
IUdpCommunication::~IUdpCommunication
virtual ~IUdpCommunication()=default
Destroy the IUdpCommunication object.
IUdpCommunication::send
virtual void send(std::vector< byte > const &data)=0
A method to send a message to the already known ip adress and port adress.
IUdpCommunication::receive
virtual std::pair< asio::ip::address, unsigned short > receive(std::vector< byte > &data)=0
A method to receive a message.