JSON-RPC 2.0
JSON-RPC 2.0 Modern C++ Library
Loading...
Searching...
No Matches
pipe_transport.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <asio.hpp>
4#include <string>
5
7
8namespace jsonrpc::transport {
9
17class PipeTransport : public Transport {
18 public:
25 PipeTransport(const std::string &socket_path, bool is_server);
26
27 ~PipeTransport() override;
28
29 PipeTransport(const PipeTransport &) = delete;
30 auto operator=(const PipeTransport &) -> PipeTransport & = delete;
31
33 auto operator=(PipeTransport &&) -> PipeTransport & = delete;
34
35 void SendMessage(const std::string &message) override;
36 auto ReceiveMessage() -> std::string override;
37
38 protected:
39 auto GetSocket() -> asio::local::stream_protocol::socket &;
40
41 private:
42 void RemoveExistingSocketFile();
43 void Connect();
44 void BindAndListen();
45
46 asio::io_context io_context_;
47 asio::local::stream_protocol::socket socket_;
48 std::string socket_path_;
49 bool is_server_;
50};
51
52} // namespace jsonrpc::transport
Transport implementation using Unix domain sockets.
void SendMessage(const std::string &message) override
Sends a message in string to the transport layer.
PipeTransport(PipeTransport &&)=delete
auto GetSocket() -> asio::local::stream_protocol::socket &
PipeTransport(const std::string &socket_path, bool is_server)
Constructs a PipeTransport.
auto operator=(PipeTransport &&) -> PipeTransport &=delete
auto operator=(const PipeTransport &) -> PipeTransport &=delete
auto ReceiveMessage() -> std::string override
Receives a message from the transport layer.
PipeTransport(const PipeTransport &)=delete
Base class for JSON-RPC transport.
Definition transport.hpp:12