TSDuck v3.45-4766
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::ReactiveTLVStream Class Reference

TLV-messages stream for use in a Reactor environment. More...

#include <tsReactiveTLVStream.h>

Inheritance diagram for ts::ReactiveTLVStream:
Collaboration diagram for ts::ReactiveTLVStream:

Public Member Functions

 ReactiveTLVStream (tlv::Logger &logger, const tlv::Protocol &protocol, ReactiveStream &stream, bool auto_error_response=true, size_t max_invalid_msg=0)
 Constructor.
 
bool getAutoErrorResponse () const
 Get invalid incoming messages processing.
 
size_t getMaxInvalidMessages () const
 Get invalid message threshold.
 
void setAutoErrorResponse (bool on)
 Set invalid incoming messages processing.
 
void setMaxInvalidMessages (size_t n)
 Set invalid message threshold.
 
bool startReceive (ReactiveTLVStreamHandlerInterface *handler, size_t buffer_size=ReactiveStream::DEFAULT_RECEIVE_BUFFER_SIZE, const ObjectPtr &user_data=ObjectPtr())
 Start the operation of receiving messages from the stream.
 
bool startSendMessage (ReactiveTLVStreamHandlerInterface *handler, const tlv::Message &msg, const ObjectPtr &user_data=ObjectPtr())
 Start the operation of sending a message over the stream.
 
ReactiveStreamstream ()
 Get a reference to the associated reactive stream.
 

Detailed Description

TLV-messages stream for use in a Reactor environment.

The class ReactiveTLVStream is a wrapper around ReactiveStream to handle reactive I/O.

Constructor & Destructor Documentation

◆ ReactiveTLVStream()

ts::ReactiveTLVStream::ReactiveTLVStream ( tlv::Logger logger,
const tlv::Protocol protocol,
ReactiveStream stream,
bool  auto_error_response = true,
size_t  max_invalid_msg = 0 
)

Constructor.

Parameters
[in,out]loggerWhere to report errors and messages. An internal reference is kept. The logger object must remain valid as long as this object exists.
[in]protocolThe incoming messages are interpreted according to this protocol. The reference is kept in this object.
[in,out]streamAssociated reactive stream device. The device object must remain valid as long as this object is valid.
[in]auto_error_responseWhen 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_msgWhen 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.

Member Function Documentation

◆ stream()

ReactiveStream & ts::ReactiveTLVStream::stream ( )
inline

Get a reference to the associated reactive stream.

Returns
A reference to the associated reactive stream.

◆ startSendMessage()

bool ts::ReactiveTLVStream::startSendMessage ( ReactiveTLVStreamHandlerInterface handler,
const tlv::Message msg,
const ObjectPtr user_data = ObjectPtr() 
)

Start the operation of sending a message over the stream.

Parameters
[in]handlerHandler class to call when the write operation is complete.
[in]msgThe message to send.
[in]user_dataA 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()

bool ts::ReactiveTLVStream::startReceive ( ReactiveTLVStreamHandlerInterface handler,
size_t  buffer_size = ReactiveStream::DEFAULT_RECEIVE_BUFFER_SIZE,
const ObjectPtr user_data = ObjectPtr() 
)

Start the operation of receiving messages from the stream.

Parameters
[in]handlerHandler class to call each time a message is received. Cannot be null. If a previous receive handler was registered, it is replaced.
[in]buffer_sizeSize of input buffers to receive data. This is a tuning parameter only. It is automatically increased when necessary.
[in]user_dataA 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]onWhen 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]nWhen 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: