Line-oriented Telnet-like connection for use in a Reactor environment.
More...
#include <tsReactiveTextStream.h>
|
| | ReactiveTextStream (ReactiveStream &stream, const std::string &eol=TextStream::DEFAULT_EOL) |
| | Constructor.
|
| |
|
virtual | ~ReactiveTextStream () override |
| | Destructor.
|
| |
| void | setEOL (const std::string &eol) |
| | Set a new end-of-line sequence for output lines.
|
| |
| bool | startReadText (ReactiveTextStreamHandlerInterface *handler, size_t buffer_size=ReactiveStream::DEFAULT_RECEIVE_BUFFER_SIZE, const ObjectPtr &user_data=ObjectPtr()) |
| | Start the operation of receiving messages from the socket.
|
| |
| bool | startWriteLine (ReactiveTextStreamHandlerInterface *handler, const std::string &line, bool flush=true, const ObjectPtr &user_data=ObjectPtr()) |
| | Start the operation of sending a line of text over the stream device.
|
| |
| bool | startWriteLine (ReactiveTextStreamHandlerInterface *handler, const UString &line, bool flush=true, const ObjectPtr &user_data=ObjectPtr()) |
| | Start the operation of sending a line of text over the stream device.
|
| |
| bool | startWriteText (ReactiveTextStreamHandlerInterface *handler, const std::string &text, bool flush=true, const ObjectPtr &user_data=ObjectPtr()) |
| | Start the operation of sending text over the stream device.
|
| |
| bool | startWriteText (ReactiveTextStreamHandlerInterface *handler, const UString &text, bool flush=true, const ObjectPtr &user_data=ObjectPtr()) |
| | Start the operation of sending text over the stream device.
|
| |
| ReactiveStream & | stream () |
| | Get a reference to the associated reactive stream device.
|
| |
Line-oriented Telnet-like connection for use in a Reactor environment.
The class ReactiveTextStream is a wrapper around ReactiveStream to handle reactive I/O.
◆ ReactiveTextStream()
Constructor.
- Parameters
-
| [in,out] | stream | Associated stream device. The device object must remain valid as long as this object is valid. |
| [in] | eol | End-of-file sequence to send at end of each line. Input is auto-adaptive: a line is always read up to a LF character and all previous CR characters are discarded. |
◆ setEOL()
| void ts::ReactiveTextStream::setEOL |
( |
const std::string & |
eol | ) |
|
|
inline |
Set a new end-of-line sequence for output lines.
Input is auto-adaptive: a line is always read up to a LF character and all previous CR characters are discarded.
- Parameters
-
| [in] | eol | End-of-file sequence to send at end of each line. |
◆ stream()
Get a reference to the associated reactive stream device.
- Returns
- A reference to the associated reactive stream device.
◆ startWriteLine() [1/2]
Start the operation of sending a line of text over the stream device.
- Parameters
-
| [in] | handler | Handler class to call when the write operation is complete. Ignored when flush is false. |
| [in] | line | Text line to send. The corresponding memory area is no longer used upon return. An end-of-line marker is automatically added. |
| [in] | flush | If false, data are buffered into the ReactiveTextStream and no completion handler will be called. When true, all previously buffered data are sent with data from this call. |
| [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.
◆ startWriteLine() [2/2]
Start the operation of sending a line of text over the stream device.
- Parameters
-
| [in] | handler | Handler class to call when the write operation is complete. Ignored when flush is false. |
| [in] | line | Text line to send. The corresponding memory area is no longer used upon return. An end-of-line marker is automatically added. |
| [in] | flush | If false, data are buffered into the ReactiveTextStream and no completion handler will be called. When true, all previously buffered data are sent with data from this call. |
| [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.
◆ startWriteText() [1/2]
Start the operation of sending text over the stream device.
- Parameters
-
| [in] | handler | Handler class to call when the write operation is complete. Ignored when flush is false. |
| [in] | text | Text to send. The corresponding memory area is no longer used upon return. No end-of-line marker is added. |
| [in] | flush | If false, data are buffered into the ReactiveTextStream and no completion handler will be called. When true, all previously buffered data are sent with data from this call. |
| [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.
◆ startWriteText() [2/2]
Start the operation of sending text over the stream device.
- Parameters
-
| [in] | handler | Handler class to call when the write operation is complete. Ignored when flush is false. |
| [in] | text | Text to send. The corresponding memory area is no longer used upon return. No end-of-line marker is added. |
| [in] | flush | If false, data are buffered into the ReactiveTextStream and no completion handler will be called. When true, all previously buffered data are sent with data from this call. |
| [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.
◆ startReadText()
Start the operation of receiving messages from the socket.
- Parameters
-
| [in] | handler | Handler class to call each time a text line is received. The method handleTextLine() will be called on each received line. Cannot be null. If a previous receive handler was registered, it is replaced. |
| [in] | buffer_size | Size of input buffers to receive data. |
| [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.
The documentation for this class was generated from the following file: