cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
msgpack_rpc::transport::ConnectionWrapper Class Reference

Class to wrap IConnection objects with template functions. More...

#include <msgpack_rpc/transport/connection_wrapper.h>

Collaboration diagram for msgpack_rpc::transport::ConnectionWrapper:

Public Types

using ConnectionClosedCallback = IConnection::ConnectionClosedCallback
 Type of callback functions called when a connection is closed.
using MessageReceivedCallback = IConnection::MessageReceivedCallback
 Type of callback functions called when a message is received.
using MessageSentCallback = IConnection::MessageSentCallback
 Type of callback functions called when a message is successfully sent.

Public Member Functions

 ConnectionWrapper (std::shared_ptr< IConnection > connection) noexcept
 Constructor.
void async_close ()
 Asynchronously close this connection.
template<typename... Parameters>
void async_notify (messages::MethodNameView method_name, const Parameters &... parameters)
 Asynchronously send a notification.
template<typename... Parameters>
void async_request (messages::MethodNameView method_name, messages::MessageID message_id, const Parameters &... parameters)
 Asynchronously send a request.
template<typename T>
void async_response_error (messages::MessageID request_id, const T &error)
 Asynchronously send a response with an error.
template<typename T>
void async_response_success (messages::MessageID request_id, const T &result)
 Asynchronously send a response without an error.
std::shared_ptr< IConnectionconnection () const noexcept
 Get the IConnection object of this wrapper.
const addresses::IAddresslocal_address () const noexcept
 Get the address of the local endpoint.
const addresses::IAddressremote_address () const noexcept
 Get the address of the remote endpoint.
void start (MessageReceivedCallback on_received, MessageSentCallback on_sent, ConnectionClosedCallback on_closed)
 Start process of this connection.

Private Attributes

std::shared_ptr< IConnectionconnection_
 Connection.

Detailed Description

Class to wrap IConnection objects with template functions.

Definition at line 36 of file connection_wrapper.h.

Member Typedef Documentation

◆ ConnectionClosedCallback

Type of callback functions called when a connection is closed.

Parameters:

  1. Status object specifying the reason.

Definition at line 60 of file connection_wrapper.h.

◆ MessageReceivedCallback

Type of callback functions called when a message is received.

Parameters:

  1. Received message.

Definition at line 45 of file connection_wrapper.h.

◆ MessageSentCallback

Type of callback functions called when a message is successfully sent.

Definition at line 51 of file connection_wrapper.h.

Constructor & Destructor Documentation

◆ ConnectionWrapper()

msgpack_rpc::transport::ConnectionWrapper::ConnectionWrapper ( std::shared_ptr< IConnection > connection)
inlineexplicitnoexcept

Constructor.

Parameters
[in]connectionConnection.

Definition at line 67 of file connection_wrapper.h.

Member Function Documentation

◆ async_close()

void msgpack_rpc::transport::ConnectionWrapper::async_close ( )
inline

Asynchronously close this connection.

Definition at line 148 of file connection_wrapper.h.

◆ async_notify()

template<typename... Parameters>
void msgpack_rpc::transport::ConnectionWrapper::async_notify ( messages::MethodNameView method_name,
const Parameters &... parameters )
inline

Asynchronously send a notification.

Template Parameters
ParametersTypes of parameters.
Parameters
[in]method_nameMethod name.
[in]parametersParameters.

Definition at line 138 of file connection_wrapper.h.

◆ async_request()

template<typename... Parameters>
void msgpack_rpc::transport::ConnectionWrapper::async_request ( messages::MethodNameView method_name,
messages::MessageID message_id,
const Parameters &... parameters )
inline

Asynchronously send a request.

Template Parameters
ParametersTypes of parameters.
Parameters
[in]method_nameMethod name.
[in]message_idMessage ID.
[in]parametersParameters.

Definition at line 95 of file connection_wrapper.h.

◆ async_response_error()

template<typename T>
void msgpack_rpc::transport::ConnectionWrapper::async_response_error ( messages::MessageID request_id,
const T & error )
inline

Asynchronously send a response with an error.

Template Parameters
TType of the error.
Parameters
[in]request_idMessage ID of the request.
[in]errorError.

Definition at line 124 of file connection_wrapper.h.

◆ async_response_success()

template<typename T>
void msgpack_rpc::transport::ConnectionWrapper::async_response_success ( messages::MessageID request_id,
const T & result )
inline

Asynchronously send a response without an error.

Template Parameters
TType of the result.
Parameters
[in]request_idMessage ID of the request.
[in]resultResult.

Definition at line 109 of file connection_wrapper.h.

◆ connection()

std::shared_ptr< IConnection > msgpack_rpc::transport::ConnectionWrapper::connection ( ) const
inlinenodiscardnoexcept

Get the IConnection object of this wrapper.

Returns
Pointer of the IConnection object.

Definition at line 173 of file connection_wrapper.h.

◆ local_address()

const addresses::IAddress & msgpack_rpc::transport::ConnectionWrapper::local_address ( ) const
inlinenodiscardnoexcept

Get the address of the local endpoint.

Returns
Address.

Definition at line 155 of file connection_wrapper.h.

◆ remote_address()

const addresses::IAddress & msgpack_rpc::transport::ConnectionWrapper::remote_address ( ) const
inlinenodiscardnoexcept

Get the address of the remote endpoint.

Returns
Address.

Definition at line 164 of file connection_wrapper.h.

◆ start()

void msgpack_rpc::transport::ConnectionWrapper::start ( MessageReceivedCallback on_received,
MessageSentCallback on_sent,
ConnectionClosedCallback on_closed )
inline

Start process of this connection.

Parameters
[in]on_receivedCallback function called when a message is received.
[in]on_sentCallback function called when a message is sent.
[in]on_closedCallback function called when this connection is closed.

Definition at line 80 of file connection_wrapper.h.

Member Data Documentation

◆ connection_

std::shared_ptr<IConnection> msgpack_rpc::transport::ConnectionWrapper::connection_
private

Connection.

Definition at line 179 of file connection_wrapper.h.


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