cpp-msgpack-rpc
0.2.0
An RPC library implementing MessagePack RPC.
Toggle main menu visibility
Loading...
Searching...
No Matches
i_connection.h
Go to the documentation of this file.
1
/*
2
* Copyright 2023 MusicScience37 (Kenta Kabashima)
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
20
#pragma once
21
22
#include <functional>
23
24
#include "
msgpack_rpc/addresses/i_address.h
"
25
#include "
msgpack_rpc/common/status.h
"
26
#include "
msgpack_rpc/messages/parsed_message.h
"
27
#include "
msgpack_rpc/messages/serialized_message.h
"
28
29
namespace
msgpack_rpc::transport
{
30
34
class
IConnection {
35
public
:
43
using
MessageReceivedCallback
=
44
std::function<void(
messages::ParsedMessage
)>;
45
50
using
MessageSentCallback
= std::function<void()>;
51
59
using
ConnectionClosedCallback
= std::function<void(
const
Status
&)>;
60
71
virtual
void
start
(
MessageReceivedCallback
on_received,
72
MessageSentCallback
on_sent,
ConnectionClosedCallback
on_closed) = 0;
73
79
virtual
void
async_send
(
const
messages::SerializedMessage
& message) = 0;
80
84
virtual
void
async_close
() = 0;
85
91
[[nodiscard]]
virtual
const
addresses::IAddress
&
local_address
()
92
const noexcept = 0;
93
99
[[nodiscard]] virtual const
addresses
::IAddress&
remote_address
()
100
const noexcept = 0;
101
102
IConnection(const IConnection&) = delete;
103
IConnection(IConnection&&) = delete;
104
IConnection& operator=(const IConnection&) = delete;
105
IConnection& operator=(IConnection&&) = delete;
106
108
virtual ~IConnection() noexcept = default;
109
110
protected:
112
IConnection() noexcept = default;
113
};
114
115
}
// namespace msgpack_rpc::transport
msgpack_rpc::addresses::IAddress
Interface of addresses.
Definition
i_address.h:31
msgpack_rpc::Status
Class of statuses.
Definition
status.h:34
msgpack_rpc::messages::SerializedMessage
Class of serialized message data.
Definition
serialized_message.h:34
msgpack_rpc::transport::IConnection::start
virtual void start(MessageReceivedCallback on_received, MessageSentCallback on_sent, ConnectionClosedCallback on_closed)=0
Start process of this connection.
msgpack_rpc::transport::IConnection::remote_address
virtual const addresses::IAddress & remote_address() const noexcept=0
Get the address of the remote endpoint.
msgpack_rpc::transport::IConnection::MessageReceivedCallback
std::function< void(messages::ParsedMessage)> MessageReceivedCallback
Type of callback functions called when a message is received.
Definition
i_connection.h:43
msgpack_rpc::transport::IConnection::ConnectionClosedCallback
std::function< void(const Status &)> ConnectionClosedCallback
Type of callback functions called when a connection is closed.
Definition
i_connection.h:59
msgpack_rpc::transport::IConnection::MessageSentCallback
std::function< void()> MessageSentCallback
Type of callback functions called when a message is successfully sent.
Definition
i_connection.h:50
msgpack_rpc::transport::IConnection::async_close
virtual void async_close()=0
Asynchronously close this connection.
msgpack_rpc::transport::IConnection::local_address
virtual const addresses::IAddress & local_address() const noexcept=0
Get the address of the local endpoint.
msgpack_rpc::transport::IConnection::async_send
virtual void async_send(const messages::SerializedMessage &message)=0
Asynchronously send a message.
i_address.h
Definition of IAddress.
msgpack_rpc::addresses
Namespace of addresses.
Definition
i_address.h:26
msgpack_rpc::messages::ParsedMessage
std::variant< ParsedRequest, ParsedResponse, ParsedNotification > ParsedMessage
Type of parsed messages.
Definition
parsed_message.h:33
msgpack_rpc::transport
Namespace of transport of messages.
Definition
backends.h:31
parsed_message.h
Definition of ParsedMessage type.
serialized_message.h
Definition of SerializedMessage class.
status.h
Definition of Status class.
include
msgpack_rpc
transport
i_connection.h
Generated on
for cpp-msgpack-rpc by
1.18.0