Kagome
Polkadot Runtime Engine in C++17
kagome::api::JRpcServer Class Referenceabstract

#include <jrpc_server.hpp>

Inheritance diagram for kagome::api::JRpcServer:
Collaboration diagram for kagome::api::JRpcServer:

Public Types

using Method = jsonrpc::MethodWrapper::Method
 
using ResponseHandler = std::function< void(std::string_view)>
 
using FormatterHandler = std::function< void(outcome::result< std::string_view >)>
 

Public Member Functions

virtual ~JRpcServer ()=default
 
virtual void registerHandler (const std::string &name, Method method)=0
 registers rpc request handler lambda More...
 
virtual std::vector< std::string > getHandlerNames ()=0
 
virtual void processJsonData (std::string method_name, const jsonrpc::Request::Parameters &from, const FormatterHandler &cb)=0
 creates valid jsonrpc response More...
 
virtual void processData (std::string_view request, const ResponseHandler &cb)=0
 handles decoded network message More...
 

Detailed Description

Instance of json rpc server, allows to register callbacks for rpc methods and then invoke them

Definition at line 23 of file jrpc_server.hpp.

Member Typedef Documentation

using kagome::api::JRpcServer::FormatterHandler = std::function<void(outcome::result<std::string_view>)>

Definition at line 46 of file jrpc_server.hpp.

using kagome::api::JRpcServer::Method = jsonrpc::MethodWrapper::Method

Definition at line 25 of file jrpc_server.hpp.

using kagome::api::JRpcServer::ResponseHandler = std::function<void(std::string_view)>

Response callback type

Definition at line 44 of file jrpc_server.hpp.

Constructor & Destructor Documentation

virtual kagome::api::JRpcServer::~JRpcServer ( )
virtualdefault

Member Function Documentation

virtual std::vector<std::string> kagome::api::JRpcServer::getHandlerNames ( )
pure virtual
Returns
name of handlers

Implemented in kagome::api::JRpcServerImpl.

virtual void kagome::api::JRpcServer::processData ( std::string_view  request,
const ResponseHandler cb 
)
pure virtual

handles decoded network message

Parameters
requestjson request string
cbcallback

Implemented in kagome::api::JRpcServerImpl.

virtual void kagome::api::JRpcServer::processJsonData ( std::string  method_name,
const jsonrpc::Request::Parameters &  from,
const FormatterHandler cb 
)
pure virtual

creates valid jsonrpc response

Parameters
method_nameis a name of the method in jsonrpc call
fromis a data source
cbcallback

Implemented in kagome::api::JRpcServerImpl.

virtual void kagome::api::JRpcServer::registerHandler ( const std::string &  name,
Method  method 
)
pure virtual

registers rpc request handler lambda

Parameters
namerpc method name
methodhandler functor

Implemented in kagome::api::JRpcServerImpl.


The documentation for this class was generated from the following file: