Exchanging TLV messages over a stream device.
More...
#include <tsTLVStream.h>
Exchanging TLV messages over a stream device.
◆ TLVStream()
Constructor.
- Parameters
-
| [in,out] | logger | Where to report errors and messages. 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 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 stream device.
- Returns
- A reference to the associated stream device.
◆ sendMessage()
Serialize and send a TLV message.
- Parameters
-
| [in] | msg | The message to send. |
- Returns
- True on success, false on error.
◆ receiveMessage()
Receive a TLV message.
Wait for the message, deserialize it and validate it. Process invalid messages and loop until a valid message is received.
- Parameters
-
| [out] | msg | A safe pointer to the received message. |
| [in] | abort | If non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry). |
- Returns
- True on success, false on error.
◆ getAutoErrorResponse()
| bool ts::TLVStream::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::TLVStream::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::TLVStream::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::TLVStream::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. |
◆ handleSocketConnected()
| virtual void ts::TLVStream::handleSocketConnected |
( |
TCPConnection & |
sock | ) |
|
|
overrideprotectedvirtual |
Called when a TCP socket is successfully connected.
- Parameters
-
| [in,out] | sock | Socket for which the handler is invoked. |
Reimplemented from ts::SocketHandlerInterface.
◆ handleSocketOpenStart()
| virtual void ts::SocketHandlerInterface::handleSocketOpenStart |
( |
Socket & |
sock | ) |
|
|
virtualinherited |
Called when a socket is about to be opened.
Never called when the application tries to open a socket which is already open.
- Parameters
-
| [in,out] | sock | Socket for which the handler is invoked. |
◆ handleSocketOpenComplete()
| virtual void ts::SocketHandlerInterface::handleSocketOpenComplete |
( |
Socket & |
sock, |
|
|
bool |
success |
|
) |
| |
|
virtualinherited |
Called after a socket is opened (or failed to open).
- Parameters
-
| [in,out] | sock | Socket for which the handler is invoked. |
| [in] | success | True if the open was successful, false if the open failed. In case of error, the socket shall be considered as closed. |
◆ handleSocketDisconnected()
| virtual void ts::SocketHandlerInterface::handleSocketDisconnected |
( |
TCPConnection & |
sock, |
|
|
bool |
silent |
|
) |
| |
|
virtualinherited |
Called when a TCP socket is disconnected.
- Parameters
-
| [in,out] | sock | Socket for which the handler is invoked. |
| [in] | silent | Same value as passed to disconnect() or close(). |
◆ handleSocketCloseStart()
| virtual void ts::SocketHandlerInterface::handleSocketCloseStart |
( |
Socket & |
sock, |
|
|
bool |
silent |
|
) |
| |
|
virtualinherited |
Called when a socket is about to be closed.
Never called when the application tries to close a socket which is not open.
- Parameters
-
| [in,out] | sock | Socket for which the handler is invoked. |
| [in] | silent | Same value as passed to close(). |
◆ handleSocketCloseComplete()
| virtual void ts::SocketHandlerInterface::handleSocketCloseComplete |
( |
Socket & |
sock, |
|
|
bool |
silent, |
|
|
bool |
success |
|
) |
| |
|
virtualinherited |
Called after a socket is closed.
- Parameters
-
| [in,out] | sock | Socket for which the handler is invoked. |
| [in] | silent | Same value as passed to close(). |
| [in] | success | True if the close was successful, false if there was an error during the close. The socket shall be considered as closed on all cases, regardless of success. |
The documentation for this class was generated from the following file: