JSON-RPC 2.0
JSON-RPC 2.0 Modern C++ Library
Loading...
Searching...
No Matches
stdio_transport.cpp
Go to the documentation of this file.
1
#include "
jsonrpc/transport/stdio_transport.hpp
"
2
3
#include <iostream>
4
5
#include <spdlog/spdlog.h>
6
7
namespace
jsonrpc::transport
{
8
9
void
StdioTransport::SendMessage
(
const
std::string &message) {
10
spdlog::debug(
"StdioTransport sending message: {}"
, message);
11
std::cout << message << std::endl;
12
}
13
14
auto
StdioTransport::ReceiveMessage
() -> std::string {
15
std::string response;
16
if
(!std::getline(std::cin, response)) {
17
throw
std::runtime_error(
"Failed to receive message"
);
18
}
19
spdlog::debug(
"StdioTransport received response: {}"
, response);
20
return
response;
21
}
22
23
}
// namespace jsonrpc::transport
jsonrpc::transport::StdioTransport::ReceiveMessage
auto ReceiveMessage() -> std::string override
Receives a message from the transport layer.
Definition
stdio_transport.cpp:14
jsonrpc::transport::StdioTransport::SendMessage
void SendMessage(const std::string &message) override
Sends a message in string to the transport layer.
Definition
stdio_transport.cpp:9
jsonrpc::transport
Definition
framed_pipe_transport.hpp:10
stdio_transport.hpp
src
transport
stdio_transport.cpp
Generated by
1.11.0