cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
i_acceptor.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#include <memory>
24
27
28namespace msgpack_rpc::transport {
29
33class IAcceptor {
34public:
43 std::function<void(std::shared_ptr<IConnection>)>;
44
51 virtual void start(ConnectionCallback on_connection) = 0;
52
56 virtual void stop() = 0;
57
63 [[nodiscard]] virtual const addresses::IAddress& local_address()
64 const noexcept = 0;
65
66 IAcceptor(const IAcceptor&) = delete;
67 IAcceptor(IAcceptor&&) = delete;
68 IAcceptor& operator=(const IAcceptor&) = delete;
69 IAcceptor& operator=(IAcceptor&&) = delete;
70
72 virtual ~IAcceptor() noexcept = default;
73
74protected:
76 IAcceptor() noexcept = default;
77};
78
79} // namespace msgpack_rpc::transport
Interface of addresses.
Definition i_address.h:31
std::function< void(std::shared_ptr< IConnection >)> ConnectionCallback
Type of callback functions called when a connection is accepted.
Definition i_acceptor.h:42
virtual void start(ConnectionCallback on_connection)=0
Start process of this acceptor.
virtual const addresses::IAddress & local_address() const noexcept=0
Get the address of the local endpoint.
virtual void stop()=0
Stop this acceptor.
Definition of IAddress.
Definition of IConnection class.
Namespace of transport of messages.
Definition backends.h:31