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.
2
3#include <iostream>
4
5#include <spdlog/spdlog.h>
6
7namespace jsonrpc::transport {
8
9void StdioTransport::SendMessage(const std::string &message) {
10 spdlog::debug("StdioTransport sending message: {}", message);
11 std::cout << message << std::endl;
12}
13
14auto 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
auto ReceiveMessage() -> std::string override
Receives a message from the transport layer.
void SendMessage(const std::string &message) override
Sends a message in string to the transport layer.