TLV-messages connection for use in a Reactor environment.
More...
#include <tsReactiveTLVConnection.h>
TLV-messages connection for use in a Reactor environment.
The class ReactiveTLVConnection is a wrapper around ReactiveTCPConnection to handle reactive I/O.
◆ ReactiveTLVConnection()
Constructor.
- Parameters
-
| [in,out] | logger | Where to report errors and messages. An internal reference is kept. The logger object must remain valid as long as this object exists. |
| [in] | protocol | The incoming messages are interpreted according to this protocol. The reference is kept in this object. |
| [in,out] | socket | Associated reactive TCP socket. The socket object must remain valid as long as this object is valid. |
| [in] | auto_error_response | When an invalid message is received, the corresponding error message is automatically sent back to the sender when auto_error_response is true. |
| [in] | max_invalid_msg | When non-zero, the connection is automatically disconnected when the number of consecutive invalid messages has reached this value. |
| [in] | owner | Optional address of an "owner" object, typically an instance of class containing this object. |
◆ socket()
Get a reference to the associated socket.
- Returns
- A reference to the associated socket.
◆ startSendMessage()
| bool ts::ReactiveTLVConnection::startSendMessage |
( |
const tlv::Message & |
msg | ) |
|
Start the operation of sending a message over the TCP connection.
There is no completion handler because the serialized data to send is kept in a dedicated buffer.
- Parameters
-
| [in] | msg | The message to send. |
- Returns
- True on success, false on error. Success means that the I/O was successfully started.
◆ startReceive()
Start the operation of receiving messages from the socket.
- Parameters
-
| [in] | handler | Handler class to call each time a message is received. Cannot be null. If a previous receive handler was registered, it is replaced. |
| [in] | buffer_size | Size of input buffers to receive data. This is a tuning parameter only. It is automatically increased when necessary. |
- Returns
- True on success, false on error. Success means that the I/O was successfully started. The final status of the I/O will be transmitted in the handler.
◆ getAutoErrorResponse()
| bool ts::ReactiveTLVConnection::getAutoErrorResponse |
( |
| ) |
const |
|
inline |
Get invalid incoming messages processing.
- Returns
- True if, when an invalid message is received, the corresponding error message is automatically sent back to the sender.
◆ setAutoErrorResponse()
| void ts::ReactiveTLVConnection::setAutoErrorResponse |
( |
bool |
on | ) |
|
|
inline |
Set invalid incoming messages processing.
- Parameters
-
| [in] | on | When an invalid message is received, the corresponding error message is automatically sent back to the sender when on is true. |
◆ getMaxInvalidMessages()
| size_t ts::ReactiveTLVConnection::getMaxInvalidMessages |
( |
| ) |
const |
|
inline |
Get invalid message threshold.
- Returns
- When non-zero, the connection is automatically disconnected when the number of consecutive invalid messages has reached this value.
◆ setMaxInvalidMessages()
| void ts::ReactiveTLVConnection::setMaxInvalidMessages |
( |
size_t |
n | ) |
|
|
inline |
Set invalid message threshold.
- Parameters
-
| [in] | n | When non-zero, the connection is automatically disconnected when the number of consecutive invalid messages has reached this value. |
◆ owner() [1/2]
| Object * ts::OwnedObject::owner |
( |
| ) |
|
|
inlineinherited |
Get the address of the optional "owner" object which was specified in the constructor.
- Returns
- Address of the "owner" object or a null pointer if there was none.
◆ owner() [2/2]
template<class OBJECT >
requires std::derived_from<OBJECT,
ts::Object>
| OBJECT * ts::OwnedObject::owner |
( |
| ) |
|
|
inherited |
Get the address of the "owner" object which was specified in the constructor.
This template version requires that the owner objet is set and of type OBJECT, or some subclass of it. If there is no owner object or if it is not compatible with the template class OBJECT, this is a fatal error and the application is terminated.
- Template Parameters
-
- Returns
- Address of the "owner" object or a null pointer if there was none.
◆ isOwned() [1/2]
| bool ts::OwnedObject::isOwned |
( |
| ) |
|
|
inlineinherited |
Check if the object is owned.
- Returns
- True if this object has an owner, false otherwise.
◆ isOwned() [2/2]
template<class OBJECT >
requires std::derived_from<OBJECT,
ts::Object>
| bool ts::OwnedObject::isOwned |
( |
| ) |
|
|
inlineinherited |
Check if the object is owned by an object of a given type.
- Template Parameters
-
- Returns
- True if this object has an owner by an object of type OBJECT, false otherwise.
The documentation for this class was generated from the following file: