Babel
Epitech's C++ VoIP project
|
Asio implementation of a tcp communication. More...
#include <AsioTCPConnection.hpp>
Public Member Functions | |
void | connect (const std::string &hostname, uint16_t port) override |
connect to a hostname and a port More... | |
void | disconnect () override |
disconnect the connection More... | |
bool | isConnected () const override |
Tells if the connection is up. More... | |
void | send (Message< T > message) override |
Send the message. More... | |
void | readForMessages () override |
listen for new messages More... | |
uint64_t | getId () const override |
Get the id of this connection. More... | |
std::string | getPeerIp () const override |
Get the connected pair address. More... | |
uint16_t | getPeerPort () const override |
get the connected pair port More... | |
void | setId (uint64_t id) override |
set the id of the connection More... | |
void | setCallbackOnMessage (std::function< void(Message< T >)> callMessageReceived) override |
set the callback to be called when a message is received More... | |
AsioTCPConnection (asio::io_context &ioContext, asio::ip::tcp::socket socket) | |
~AsioTCPConnection () override | |
![]() | |
virtual | ~ITCPConnection ()=default |
default dtor More... | |
Private Member Functions | |
void | writeHeader () |
write a message header More... | |
void | writeBody () |
write a message body More... | |
void | readHeader () |
read a message header More... | |
void | readBody () |
read a message body More... | |
Private Attributes | |
asio::io_context & | _ioContext |
The asio context to link everything. More... | |
asio::ip::tcp::socket | _socket |
The connection's socket. More... | |
std::function< void(Message< T >)> | _callbackMessageReceived |
The function called when a message has been fully received. More... | |
TSQueue< Message< T > > | _messagesIn |
All the received messages. More... | |
TSQueue< Message< T > > | _messagesOut |
All the messages that need to be sent. More... | |
Message< T > | _tmpMessage |
Message used when reading a message. More... | |
uint64_t | _id |
id used to identify the connection More... | |
Asio implementation of a tcp communication.
|
explicit |
|
override |
|
overridevirtual |
connect to a hostname and a port
Implements Babel::ITCPConnection< T >.
|
overridevirtual |
disconnect the connection
Implements Babel::ITCPConnection< T >.
|
overridevirtual |
Get the id of this connection.
Implements Babel::ITCPConnection< T >.
|
overridevirtual |
Get the connected pair address.
Implements Babel::ITCPConnection< T >.
|
overridevirtual |
get the connected pair port
Implements Babel::ITCPConnection< T >.
|
overridevirtual |
Tells if the connection is up.
Implements Babel::ITCPConnection< T >.
|
private |
read a message body
|
overridevirtual |
listen for new messages
Implements Babel::ITCPConnection< T >.
|
private |
read a message header
|
overridevirtual |
Send the message.
Implements Babel::ITCPConnection< T >.
|
overridevirtual |
set the callback to be called when a message is received
Implements Babel::ITCPConnection< T >.
|
overridevirtual |
set the id of the connection
Implements Babel::ITCPConnection< T >.
|
private |
write a message body
|
private |
write a message header
|
private |
The function called when a message has been fully received.
|
private |
id used to identify the connection
|
private |
The asio context to link everything.
|
private |
All the received messages.
|
private |
All the messages that need to be sent.
|
private |
The connection's socket.
|
private |
Message used when reading a message.