irccd  3.0.3
Public Types | Public Member Functions | List of all members
irccd::stream Class Referenceabstract

Abstract stream interface. More...

#include <stream.hpp>

Inheritance diagram for irccd::stream:
irccd::basic_socket_stream< boost::asio::ssl::stream< Socket > > irccd::basic_socket_stream< Socket > irccd::test::mock_stream irccd::tls_stream< Socket >

Public Types

using recv_handler = std::function< void(std::error_code, nlohmann::json)>
 Read completion handler. More...
 
using send_handler = std::function< void(std::error_code)>
 Write completion handler. More...
 

Public Member Functions

 stream ()=default
 
virtual ~stream ()=default
 
virtual void recv (recv_handler handler)=0
 
virtual void send (const nlohmann::json &json, send_handler handler)=0
 

Detailed Description

Abstract stream interface.

Abstract I/O interface that allows reading/writing from a stream in an asynchronous manner.

The derived classes must implement non-blocking recv and send operations.

Member Typedef Documentation

◆ recv_handler

using irccd::stream::recv_handler = std::function<void (std::error_code, nlohmann::json)>

Read completion handler.

◆ send_handler

using irccd::stream::send_handler = std::function<void (std::error_code)>

Write completion handler.

Constructor & Destructor Documentation

◆ stream()

irccd::stream::stream ( )
default

Default constructor.

◆ ~stream()

virtual irccd::stream::~stream ( )
virtualdefault

Virtual destructor defaulted.

Member Function Documentation

◆ recv()

virtual void irccd::stream::recv ( recv_handler  handler)
pure virtual

Start asynchronous read.

Precondition
another read operation must not be running
handler != nullptr
Parameters
handlerthe handler

Implemented in irccd::basic_socket_stream< Socket >, irccd::basic_socket_stream< boost::asio::ssl::stream< Socket > >, and irccd::test::mock_stream.

◆ send()

virtual void irccd::stream::send ( const nlohmann::json &  json,
send_handler  handler 
)
pure virtual

Start asynchronous write.

Precondition
json.is_object()
another write operation must not be running
handler != nullptr
Parameters
jsonthe JSON message
handlerthe handler

Implemented in irccd::basic_socket_stream< Socket >, irccd::basic_socket_stream< boost::asio::ssl::stream< Socket > >, and irccd::test::mock_stream.


The documentation for this class was generated from the following file: