TLV-messages stream for use in a Reactor environment.
More...
#include <tsReactiveTLVStream.h>
TLV-messages stream for use in a Reactor environment.
The class ReactiveTLVStream is a wrapper around ReactiveStream to handle reactive I/O.
◆ ReactiveTLVStream()
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] | stream | Associated reactive stream device. The device 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. This applies only when a stream object is a subclass of TCPConnection. |
◆ stream()
Get a reference to the associated reactive stream.
- Returns
- A reference to the associated reactive stream.
◆ startSendMessage()
Start the operation of sending a message over the stream.
- Parameters
-
| [in] | handler | Handler class to call when the write operation is complete. |
| [in] | msg | The message to send. |
| [in] | user_data | A shared pointer which will be passed unmodified to handler. |
- 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 stream.
- 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. |
| [in] | user_data | A shared pointer which will be passed unmodified to handler. |
- 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::ReactiveTLVStream::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::ReactiveTLVStream::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::ReactiveTLVStream::getMaxInvalidMessages |
( |
| ) |
const |
|
inline |
Get invalid message threshold.
This applies only when a stream object is a subclass of TCPConnection.
- Returns
- When non-zero, the connection is automatically disconnected when the number of consecutive invalid messages has reached this value.
◆ setMaxInvalidMessages()
| void ts::ReactiveTLVStream::setMaxInvalidMessages |
( |
size_t |
n | ) |
|
|
inline |
Set invalid message threshold.
This applies only when a stream object is a subclass of TCPConnection.
- Parameters
-
| [in] | n | When non-zero, the connection is automatically disconnected when the number of consecutive invalid messages has reached this value. |
The documentation for this class was generated from the following file: