JSON-RPC 2.0
JSON-RPC 2.0 Modern C++ Library
|
#include <endpoint.hpp>
Public Member Functions | |
RpcEndpoint (asio::any_io_executor executor, std::unique_ptr< transport::Transport > transport, std::shared_ptr< spdlog::logger > logger=nullptr) | |
RpcEndpoint (const RpcEndpoint &)=delete | |
RpcEndpoint (RpcEndpoint &&)=delete | |
auto | operator= (const RpcEndpoint &) -> RpcEndpoint &=delete |
auto | operator= (RpcEndpoint &&) -> RpcEndpoint &=delete |
~RpcEndpoint ()=default | |
auto | Start () -> asio::awaitable< std::expected< void, RpcError > > |
auto | WaitForShutdown () -> asio::awaitable< std::expected< void, RpcError > > |
auto | Shutdown () -> asio::awaitable< std::expected< void, RpcError > > |
auto | IsRunning () const -> bool |
auto | Logger () -> std::shared_ptr< spdlog::logger > |
auto | SendMethodCall (std::string method, std::optional< nlohmann::json > params=std::nullopt) -> asio::awaitable< std::expected< nlohmann::json, RpcError > > |
template<typename ParamsType , typename ResultType > | |
auto | SendMethodCall (std::string method, ParamsType params) -> asio::awaitable< std::expected< ResultType, RpcError > > requires(ToJson< ParamsType > &&NotJsonLike< ParamsType > &&FromJson< ResultType >) |
auto | SendNotification (std::string method, std::optional< nlohmann::json > params=std::nullopt) -> asio::awaitable< std::expected< void, RpcError > > |
template<typename ParamsType > | |
auto | SendNotification (std::string method, ParamsType params) -> asio::awaitable< std::expected< void, RpcError > > requires(ToJson< ParamsType > &&NotJsonLike< ParamsType >) |
void | RegisterMethodCall (std::string method, typename Dispatcher::MethodCallHandler handler) |
template<typename ParamsType , typename ResultType > requires (FromJson<ParamsType> && ToJson<ResultType>) | |
void | RegisterMethodCall (std::string method, std::function< asio::awaitable< ResultType >(ParamsType)> handler) |
template<typename ParamsType , typename ResultType , typename ErrorType > requires (FromJson<ParamsType> && ToJson<ResultType> && ToJson<ErrorType>) | |
void | RegisterMethodCall (std::string method, std::function< asio::awaitable< std::expected< ResultType, ErrorType > >(ParamsType)> handler) |
void | RegisterNotification (std::string method, typename Dispatcher::NotificationHandler handler) |
template<typename ParamsType , typename ErrorType > requires (FromJson<ParamsType> && HasMessageMethod<ErrorType>) | |
void | RegisterNotification (std::string method, std::function< asio::awaitable< std::expected< void, ErrorType > >(ParamsType)> handler) |
auto | HasPendingRequests () const -> bool |
Static Public Member Functions | |
static auto | CreateClient (asio::any_io_executor executor, std::unique_ptr< transport::Transport > transport) -> asio::awaitable< std::expected< std::unique_ptr< RpcEndpoint >, RpcError > > |
Definition at line 26 of file endpoint.hpp.
|
explicit |
Definition at line 16 of file endpoint.cpp.
|
delete |
|
delete |
|
default |
|
static |
Definition at line 27 of file endpoint.cpp.
|
nodiscard |
Definition at line 174 of file endpoint.cpp.
|
inlinenodiscard |
Definition at line 51 of file endpoint.hpp.
|
inline |
Definition at line 55 of file endpoint.hpp.
|
delete |
|
delete |
void jsonrpc::endpoint::RpcEndpoint::RegisterMethodCall | ( | std::string | method, |
std::function< asio::awaitable< ResultType >(ParamsType)> | handler ) |
Definition at line 206 of file endpoint.hpp.
void jsonrpc::endpoint::RpcEndpoint::RegisterMethodCall | ( | std::string | method, |
std::function< asio::awaitable< std::expected< ResultType, ErrorType > >(ParamsType)> | handler ) |
Definition at line 228 of file endpoint.hpp.
void jsonrpc::endpoint::RpcEndpoint::RegisterMethodCall | ( | std::string | method, |
typename Dispatcher::MethodCallHandler | handler ) |
Definition at line 164 of file endpoint.cpp.
References jsonrpc::endpoint::Dispatcher::RegisterMethodCall().
void jsonrpc::endpoint::RpcEndpoint::RegisterNotification | ( | std::string | method, |
std::function< asio::awaitable< std::expected< void, ErrorType > >(ParamsType)> | handler ) |
Definition at line 246 of file endpoint.hpp.
void jsonrpc::endpoint::RpcEndpoint::RegisterNotification | ( | std::string | method, |
typename Dispatcher::NotificationHandler | handler ) |
Definition at line 169 of file endpoint.cpp.
References jsonrpc::endpoint::Dispatcher::RegisterNotification().
auto jsonrpc::endpoint::RpcEndpoint::SendMethodCall | ( | std::string | method, |
ParamsType | params ) -> asio::awaitable<std::expected<ResultType, RpcError>> requires( ToJson<ParamsType> && NotJsonLike<ParamsType> && FromJson<ResultType>) |
Definition at line 146 of file endpoint.hpp.
References SendMethodCall(), and jsonrpc::error::RpcError::UnexpectedFromCode().
auto jsonrpc::endpoint::RpcEndpoint::SendMethodCall | ( | std::string | method, |
std::optional< nlohmann::json > | params = std::nullopt ) -> asio::awaitable<std::expected<nlohmann::json, RpcError>> |
Definition at line 110 of file endpoint.cpp.
References jsonrpc::endpoint::Request::ToJson(), and jsonrpc::error::RpcError::UnexpectedFromCode().
Referenced by SendMethodCall().
auto jsonrpc::endpoint::RpcEndpoint::SendNotification | ( | std::string | method, |
ParamsType | params ) -> asio::awaitable<std::expected<void, RpcError>> requires(ToJson<ParamsType> && NotJsonLike<ParamsType>) |
Definition at line 180 of file endpoint.hpp.
References SendNotification(), and jsonrpc::error::RpcError::UnexpectedFromCode().
auto jsonrpc::endpoint::RpcEndpoint::SendNotification | ( | std::string | method, |
std::optional< nlohmann::json > | params = std::nullopt ) -> asio::awaitable<std::expected<void, RpcError>> |
Definition at line 143 of file endpoint.cpp.
References jsonrpc::endpoint::Request::ToJson(), and jsonrpc::error::RpcError::UnexpectedFromCode().
Referenced by SendNotification().
auto jsonrpc::endpoint::RpcEndpoint::Shutdown | ( | ) | -> asio::awaitable<std::expected<void, RpcError>> |
Definition at line 78 of file endpoint.cpp.
auto jsonrpc::endpoint::RpcEndpoint::Start | ( | ) | -> asio::awaitable<std::expected<void, RpcError>> |
Definition at line 42 of file endpoint.cpp.
References jsonrpc::error::RpcError::UnexpectedFromCode().
auto jsonrpc::endpoint::RpcEndpoint::WaitForShutdown | ( | ) | -> asio::awaitable<std::expected<void, RpcError>> |
Definition at line 64 of file endpoint.cpp.