My Project
Public Member Functions | List of all members
UdpCommunication Class Reference

Class that handle Udp Communication. More...

#include <UdpCommunication.hpp>

Inheritance diagram for UdpCommunication:
IUdpCommunication

Public Member Functions

 UdpCommunication ()=default
 Construct a new Udp Communication object.
 
 ~UdpCommunication ()
 Destroy the Udp Communication object.
 
 UdpCommunication (asio::io_context &context, asio::ip::port_type const &port)
 Construct a new Udp Communication object. More...
 
 UdpCommunication (asio::io_context &context, asio::ip::port_type const &port, std::string const &connectionPort, std::string const &ip)
 Construct a new Udp Communication object. More...
 
void send (std::vector< byte > const &data) override
 A method to send a message to the already known ip adress and port adress. More...
 
void send (std::vector< byte > const &data, asio::ip::address const &address, unsigned short const &port) override
 A method to send a message to an ip adress and port adress. More...
 
void async_send (std::vector< byte > const &data, std::function< void(std::error_code const &, std::size_t)> callBack) override
 A method to send a message to an already known ip adress and port adress in an async way. More...
 
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) override
 A method to send a message to a ip adress and port adress in an async way. More...
 
std::pair< asio::ip::address, unsigned short > receive (std::vector< byte > &data) override
 A method to receive a message. More...
 
void async_receive (std::vector< byte > &data, std::function< void(std::error_code const &, std::size_t)> callBack) override
 A method to receive a message in an async way. More...
 
std::pair< asio::ip::address, unsigned short > getEnpointInfo () const override
 Get the Enpoint Info object. More...
 
void setEnpointInfo (std::pair< asio::ip::address, unsigned short > const &endpointInfo) override
 Set the Enpoint Info object. More...
 
void setEnpointInfo (asio::ip::address const &address, unsigned short const &port) override
 Set the Enpoint Info object. More...
 
- Public Member Functions inherited from IUdpCommunication
virtual ~IUdpCommunication ()=default
 Destroy the IUdpCommunication object.
 

Detailed Description

Class that handle Udp Communication.

Constructor & Destructor Documentation

◆ UdpCommunication() [1/2]

UdpCommunication::UdpCommunication ( asio::io_context &  context,
asio::ip::port_type const &  port 
)
inline

Construct a new Udp Communication object.

Parameters
contextIO Context of the communication
portPort where start the communication

◆ UdpCommunication() [2/2]

UdpCommunication::UdpCommunication ( asio::io_context &  context,
asio::ip::port_type const &  port,
std::string const &  connectionPort,
std::string const &  ip 
)
inline

Construct a new Udp Communication object.

Parameters
contextIO Context of the communication
portPort where start the communication
connectionPortPort where connect the communication
ipIp address where connect the communication

Member Function Documentation

◆ async_receive()

void UdpCommunication::async_receive ( std::vector< byte > &  data,
std::function< void(std::error_code const &, std::size_t)>  callBack 
)
inlineoverridevirtual

A method to receive a message in an async way.

Parameters
dataThe buffer to fill when the message is received
callBackThe function called once the message is received

Implements IUdpCommunication.

◆ async_send() [1/2]

void UdpCommunication::async_send ( std::vector< byte > const &  data,
std::function< void(std::error_code const &, std::size_t)>  callBack 
)
inlineoverridevirtual

A method to send a message to an already known ip adress and port adress in an async way.

Parameters
dataThe serilized
callBackThe function to call once the message is sent

Implements IUdpCommunication.

◆ async_send() [2/2]

void UdpCommunication::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 
)
inlineoverridevirtual

A method to send a message to a ip adress and port adress in an async way.

Parameters
dataThe serialized message
callBackThe function called once the message is sent
addressThe ip adress to send the message
portThe port adress to send the message

Implements IUdpCommunication.

◆ getEnpointInfo()

std::pair<asio::ip::address, unsigned short> UdpCommunication::getEnpointInfo ( ) const
inlineoverridevirtual

Get the Enpoint Info object.

Returns
std::pair<asio::ip::address, unsigned short> Pair with the ip address and the port of the endpoint

Implements IUdpCommunication.

◆ receive()

std::pair<asio::ip::address, unsigned short> UdpCommunication::receive ( std::vector< byte > &  data)
inlineoverridevirtual

A method to receive a message.

Parameters
dataThe buffer to fill when the message is received
Returns
std::pair<asio::ip::address, unsigned short> The ip adress and the port adress where the message came from

Implements IUdpCommunication.

◆ send() [1/2]

void UdpCommunication::send ( std::vector< byte > const &  data)
inlineoverridevirtual

A method to send a message to the already known ip adress and port adress.

Parameters
dataThe serialized message

Implements IUdpCommunication.

◆ send() [2/2]

void UdpCommunication::send ( std::vector< byte > const &  data,
asio::ip::address const &  address,
unsigned short const &  port 
)
inlineoverridevirtual

A method to send a message to an ip adress and port adress.

Parameters
dataThe serialized message
addressThe ip adress to send the message
portThe port adress to send the message

Implements IUdpCommunication.

◆ setEnpointInfo() [1/2]

void UdpCommunication::setEnpointInfo ( asio::ip::address const &  address,
unsigned short const &  port 
)
inlineoverridevirtual

Set the Enpoint Info object.

Parameters
addressIp address of the endpoint
portPort of the endpoint

Implements IUdpCommunication.

◆ setEnpointInfo() [2/2]

void UdpCommunication::setEnpointInfo ( std::pair< asio::ip::address, unsigned short > const &  endpointInfo)
inlineoverridevirtual

Set the Enpoint Info object.

Parameters
endpointInfoPair with the ip address and the port of the endpoint

Implements IUdpCommunication.


The documentation for this class was generated from the following file: