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

Class to handle connections in servers. More...

#include <msgpack_rpc/servers/server_connection.h>

Inheritance diagram for msgpack_rpc::servers::ServerConnection:
Collaboration diagram for msgpack_rpc::servers::ServerConnection:

Public Member Functions

 ServerConnection (const std::shared_ptr< transport::IConnection > &connection, std::weak_ptr< executors::IExecutor > executor, std::shared_ptr< methods::IMethodProcessor > processor, std::shared_ptr< logging::Logger > logger)
 Constructor.
void start ()
 Start processing.

Private Member Functions

void on_invalid_message ()
 Handle an invalid message.
void on_notification (const messages::ParsedNotification &notification)
 Process a notification.
void on_received (messages::ParsedMessage message)
 Process a received message.
void on_request (const messages::ParsedRequest &request)
 Process a request.
void on_sent ()
 Handle the condition that a message is sent.
void send_next_if_exists ()
 Send the next message if exists.

Private Attributes

std::weak_ptr< transport::IConnectionconnection_
 Connection.
std::weak_ptr< executors::IExecutorexecutor_
 Executor.
std::string formatted_remote_address_
 Formatted remote address for logging.
std::atomic< bool > is_sending_ {false}
 Whether this connection is sending a message.
std::shared_ptr< logging::Loggerlogger_
 Logger.
std::queue< messages::SerializedMessagemessage_queue_ {}
 Messages to be sent.
std::mutex message_queue_mutex_ {}
 Mutex of message_queue_.
std::shared_ptr< methods::IMethodProcessorprocessor_
 Processor of methods.

Detailed Description

Class to handle connections in servers.

Definition at line 51 of file server_connection.h.

Constructor & Destructor Documentation

◆ ServerConnection()

msgpack_rpc::servers::ServerConnection::ServerConnection ( const std::shared_ptr< transport::IConnection > & connection,
std::weak_ptr< executors::IExecutor > executor,
std::shared_ptr< methods::IMethodProcessor > processor,
std::shared_ptr< logging::Logger > logger )
inline

Constructor.

Parameters
[in]connectionConnection.
[in]executorExecutor.
[in]processorProcessor of methods.
[in]loggerLogger.

Definition at line 61 of file server_connection.h.

Member Function Documentation

◆ on_invalid_message()

void msgpack_rpc::servers::ServerConnection::on_invalid_message ( )
inlineprivate

Handle an invalid message.

Definition at line 165 of file server_connection.h.

◆ on_notification()

void msgpack_rpc::servers::ServerConnection::on_notification ( const messages::ParsedNotification & notification)
inlineprivate

Process a notification.

Parameters
[in]notificationNotification.

Definition at line 155 of file server_connection.h.

◆ on_received()

void msgpack_rpc::servers::ServerConnection::on_received ( messages::ParsedMessage message)
inlineprivate

Process a received message.

Parameters
[in]messageMessage.

Definition at line 95 of file server_connection.h.

◆ on_request()

void msgpack_rpc::servers::ServerConnection::on_request ( const messages::ParsedRequest & request)
inlineprivate

Process a request.

Parameters
[in]requestRequest.

Definition at line 133 of file server_connection.h.

◆ on_sent()

void msgpack_rpc::servers::ServerConnection::on_sent ( )
inlineprivate

Handle the condition that a message is sent.

Definition at line 204 of file server_connection.h.

◆ send_next_if_exists()

void msgpack_rpc::servers::ServerConnection::send_next_if_exists ( )
inlineprivate

Send the next message if exists.

Definition at line 179 of file server_connection.h.

◆ start()

void msgpack_rpc::servers::ServerConnection::start ( )
inline

Start processing.

Definition at line 74 of file server_connection.h.

Member Data Documentation

◆ connection_

std::weak_ptr<transport::IConnection> msgpack_rpc::servers::ServerConnection::connection_
private

Connection.

Definition at line 211 of file server_connection.h.

◆ executor_

std::weak_ptr<executors::IExecutor> msgpack_rpc::servers::ServerConnection::executor_
private

Executor.

Definition at line 214 of file server_connection.h.

◆ formatted_remote_address_

std::string msgpack_rpc::servers::ServerConnection::formatted_remote_address_
private

Formatted remote address for logging.

Definition at line 223 of file server_connection.h.

◆ is_sending_

std::atomic<bool> msgpack_rpc::servers::ServerConnection::is_sending_ {false}
private

Whether this connection is sending a message.

Definition at line 232 of file server_connection.h.

◆ logger_

std::shared_ptr<logging::Logger> msgpack_rpc::servers::ServerConnection::logger_
private

Logger.

Definition at line 220 of file server_connection.h.

◆ message_queue_

std::queue<messages::SerializedMessage> msgpack_rpc::servers::ServerConnection::message_queue_ {}
private

Messages to be sent.

Definition at line 226 of file server_connection.h.

◆ message_queue_mutex_

std::mutex msgpack_rpc::servers::ServerConnection::message_queue_mutex_ {}
private

Mutex of message_queue_.

Definition at line 229 of file server_connection.h.

◆ processor_

std::shared_ptr<methods::IMethodProcessor> msgpack_rpc::servers::ServerConnection::processor_
private

Processor of methods.

Definition at line 217 of file server_connection.h.


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