|
cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
|
Class of connections. More...
#include <msgpack_rpc/transport/connection.h>
Public Types | |
| using | AsioSocket = AsioSocketType |
| Type of sockets in asio library. | |
| using | ConcreteAddress = ConcreteAddressType |
| Type of concrete addresses. | |
| Public Types inherited from msgpack_rpc::transport::IConnection | |
| using | ConnectionClosedCallback = std::function<void(const Status&)> |
| Type of callback functions called when a connection is closed. | |
| using | MessageReceivedCallback |
| Type of callback functions called when a message is received. | |
| using | MessageSentCallback = std::function<void()> |
| Type of callback functions called when a message is successfully sent. | |
Public Member Functions | |
| Connection (AsioSocket &&socket, const config::MessageParserConfig &message_parser_config, std::shared_ptr< logging::Logger > logger, const std::shared_ptr< ConnectionList< Connection > > &connection_list=nullptr) | |
| Constructor. | |
| Connection (Connection &&)=delete | |
| Connection (const Connection &)=delete | |
| ~Connection () override | |
| Destructor. | |
| void | async_close () override |
| Asynchronously close this connection. | |
| void | async_send (const messages::SerializedMessage &message) override |
| Asynchronously send a message. | |
| const addresses::IAddress & | local_address () const noexcept override |
| Get the address of the local endpoint. | |
| Connection & | operator= (Connection &&)=delete |
| Connection & | operator= (const Connection &)=delete |
| const addresses::IAddress & | remote_address () const noexcept override |
| Get the address of the remote endpoint. | |
| void | start (MessageReceivedCallback on_received, MessageSentCallback on_sent, ConnectionClosedCallback on_closed) override |
| Start process of this connection. | |
| Public Member Functions inherited from msgpack_rpc::transport::IConnection | |
| IConnection (const IConnection &)=delete | |
| IConnection (IConnection &&)=delete | |
| virtual | ~IConnection () noexcept=default |
| Destructor. | |
| IConnection & | operator= (const IConnection &)=delete |
| IConnection & | operator= (IConnection &&)=delete |
Private Member Functions | |
| void | async_read_next () |
| Asynchronously read next bytes. | |
| void | async_send_in_thread (const messages::SerializedMessage &message) |
| Asynchronously send a message in this thread. | |
| void | close_in_thread (const Status &status) |
| Close this connection in this thread. | |
| void | on_sent (const asio::error_code &error, std::size_t size) |
| Handle the result of send operation. | |
| void | process_read_bytes (const asio::error_code &error, std::size_t size) |
| Process read bytes. | |
Private Attributes | |
| std::weak_ptr< ConnectionList< Connection > > | connection_list_ |
| List of connections. | |
| ConcreteAddress | local_address_ |
| Address of the local endpoint. | |
| std::string | log_name_ |
| Name of the connection for logs. | |
| std::shared_ptr< logging::Logger > | logger_ |
| Logger. | |
| messages::MessageParser | message_parser_ |
| Parser of messages. | |
| ConnectionClosedCallback | on_closed_ {} |
| Callback function when this connection is closed. | |
| MessageReceivedCallback | on_received_ {} |
| Callback function when a message is received. | |
| MessageSentCallback | on_sent_ {} |
| Callback function when a message is sent. | |
| ConcreteAddress | remote_address_ |
| Address of the remote endpoint. | |
| AsioSocket | socket_ |
| Socket. | |
| BackgroundTaskStateMachine | state_machine_ {} |
| State machine. | |
Additional Inherited Members | |
| Protected Member Functions inherited from msgpack_rpc::transport::IConnection | |
| IConnection () noexcept=default | |
| Constructor. | |
Class of connections.
| AsioSocketType | Type of sockets in asio library. |
| ConcreteAddressType | Type of concrete addresses. |
Definition at line 61 of file connection.h.
| using msgpack_rpc::transport::Connection< AsioSocketType, ConcreteAddressType >::AsioSocket = AsioSocketType |
Type of sockets in asio library.
Definition at line 66 of file connection.h.
| using msgpack_rpc::transport::Connection< AsioSocketType, ConcreteAddressType >::ConcreteAddress = ConcreteAddressType |
Type of concrete addresses.
Definition at line 69 of file connection.h.
|
inline |
Constructor.
| [in] | socket | Socket. |
| [in] | message_parser_config | Configuration of the parser of messages. |
| [in] | logger | Logger. |
| [in] | connection_list | List of connections. |
Definition at line 79 of file connection.h.
|
inlineoverride |
Destructor.
Definition at line 101 of file connection.h.
|
inlineoverridevirtual |
Asynchronously close this connection.
Implements msgpack_rpc::transport::IConnection.
Definition at line 137 of file connection.h.
|
inlineprivate |
Asynchronously read next bytes.
Definition at line 159 of file connection.h.
|
inlineoverridevirtual |
Asynchronously send a message.
| [in] | message | Message to send. |
Implements msgpack_rpc::transport::IConnection.
Definition at line 125 of file connection.h.
|
inlineprivate |
Asynchronously send a message in this thread.
| [in] | message | Message. |
Definition at line 230 of file connection.h.
|
inlineprivate |
Close this connection in this thread.
| [in] | status | Status. |
Definition at line 276 of file connection.h.
|
inlinenodiscardoverridevirtualnoexcept |
Get the address of the local endpoint.
Implements msgpack_rpc::transport::IConnection.
Definition at line 144 of file connection.h.
|
inlineprivate |
Handle the result of send operation.
| [in] | error | Error. |
| [in] | size | Message size. |
Definition at line 247 of file connection.h.
|
inlineprivate |
Process read bytes.
| [in] | error | Error. |
| [in] | size | Number of bytes read to the buffer. |
Definition at line 173 of file connection.h.
|
inlinenodiscardoverridevirtualnoexcept |
Get the address of the remote endpoint.
Implements msgpack_rpc::transport::IConnection.
Definition at line 150 of file connection.h.
|
inlineoverridevirtual |
Start process of this connection.
| [in] | on_received | Callback function called when a message is received. |
| [in] | on_sent | Callback function called when a message is sent. |
| [in] | on_closed | Callback function called when this connection is closed. |
Implements msgpack_rpc::transport::IConnection.
Definition at line 109 of file connection.h.
|
private |
List of connections.
Definition at line 318 of file connection.h.
|
private |
Address of the local endpoint.
Definition at line 303 of file connection.h.
|
private |
Name of the connection for logs.
Definition at line 309 of file connection.h.
|
private |
Logger.
Definition at line 312 of file connection.h.
|
private |
Parser of messages.
Definition at line 300 of file connection.h.
|
private |
Callback function when this connection is closed.
Definition at line 297 of file connection.h.
|
private |
Callback function when a message is received.
Definition at line 291 of file connection.h.
|
private |
Callback function when a message is sent.
Definition at line 294 of file connection.h.
|
private |
Address of the remote endpoint.
Definition at line 306 of file connection.h.
|
private |
Socket.
Definition at line 288 of file connection.h.
|
private |
State machine.
Definition at line 315 of file connection.h.