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

rpc session More...

#include <session.hpp>

Inheritance diagram for kagome::api::Session:
Collaboration diagram for kagome::api::Session:

Public Types

using Context = RpcContext
 
using Socket = boost::asio::ip::tcp::socket
 
using ErrorCode = boost::system::error_code
 
using Streambuf = boost::asio::streambuf
 
using Timer = boost::asio::steady_timer
 
using Connection = boost::signals2::connection
 
using Duration = Timer::duration
 
using SessionId = uint64_t
 
using OnCloseHandler = std::function< void(SessionId, SessionType)>
 Event handlers. More...
 

Public Member Functions

virtual ~Session ()=default
 
virtual void start ()=0
 starts listening on socket More...
 
virtual Socketsocket ()=0
 
void connectOnRequest (std::function< OnRequestSignature > callback)
 connects on request callback More...
 
void connectOnCloseHandler (OnCloseHandler &&handler)
 connects on close callback More...
 
void processRequest (std::string_view request, std::shared_ptr< Session > session)
 process request message More...
 
virtual void respond (std::string_view message)=0
 send response message More...
 
void notifyOnClose (SessionId id, SessionType type)
 makes on close notification to listener More...
 
virtual SessionId id () const =0
 method to get id of the session More...
 
virtual SessionType type () const =0
 method to get type of the session More...
 

Private Types

template<class T >
using Signal = boost::signals2::signal< T >
 
using OnRequestSignature = void(std::string_view, std::shared_ptr< Session > session)
 
using OnRequest = Signal< OnRequestSignature >
 

Private Attributes

std::function< OnRequestSignatureon_request_
 on request callback More...
 
OnCloseHandler on_close_
 

Detailed Description

rpc session

Definition at line 27 of file session.hpp.

Member Typedef Documentation

using kagome::api::Session::Connection = boost::signals2::connection

Definition at line 41 of file session.hpp.

Definition at line 36 of file session.hpp.

using kagome::api::Session::Duration = Timer::duration

Definition at line 42 of file session.hpp.

using kagome::api::Session::ErrorCode = boost::system::error_code

Definition at line 38 of file session.hpp.

Event handlers.

Definition at line 46 of file session.hpp.

Definition at line 33 of file session.hpp.

using kagome::api::Session::OnRequestSignature = void(std::string_view, std::shared_ptr<Session> session)
private

Definition at line 32 of file session.hpp.

Definition at line 43 of file session.hpp.

template<class T >
using kagome::api::Session::Signal = boost::signals2::signal<T>
private

Definition at line 29 of file session.hpp.

using kagome::api::Session::Socket = boost::asio::ip::tcp::socket

Definition at line 37 of file session.hpp.

using kagome::api::Session::Streambuf = boost::asio::streambuf

Definition at line 39 of file session.hpp.

using kagome::api::Session::Timer = boost::asio::steady_timer

Definition at line 40 of file session.hpp.

Constructor & Destructor Documentation

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

Member Function Documentation

void kagome::api::Session::connectOnCloseHandler ( OnCloseHandler &&  handler)
inline

connects on close callback

Parameters
handleron close event handler

Definition at line 69 of file session.hpp.

void kagome::api::Session::connectOnRequest ( std::function< OnRequestSignature callback)
inline

connects on request callback

Parameters
callbackon request callback

Definition at line 61 of file session.hpp.

virtual SessionId kagome::api::Session::id ( ) const
pure virtual

method to get id of the session

Returns
id of the session

Implemented in kagome::api::HttpSession, and kagome::api::WsSession.

void kagome::api::Session::notifyOnClose ( SessionId  id,
SessionType  type 
)
inline

makes on close notification to listener

Parameters
idsession id
typetype of the closed session

Definition at line 93 of file session.hpp.

void kagome::api::Session::processRequest ( std::string_view  request,
std::shared_ptr< Session session 
)
inline

process request message

Parameters
requestmessage to process

Definition at line 77 of file session.hpp.

virtual void kagome::api::Session::respond ( std::string_view  message)
pure virtual

send response message

Parameters
messageresponse message

Implemented in kagome::api::WsSession, and kagome::api::HttpSession.

virtual Socket& kagome::api::Session::socket ( )
pure virtual
virtual void kagome::api::Session::start ( )
pure virtual

starts listening on socket

Implemented in kagome::api::HttpSession, and kagome::api::WsSession.

virtual SessionType kagome::api::Session::type ( ) const
pure virtual

method to get type of the session

Returns
type of the session

Implemented in kagome::api::HttpSession, and kagome::api::WsSession.

Member Data Documentation

OnCloseHandler kagome::api::Session::on_close_
private

Definition at line 111 of file session.hpp.

std::function<OnRequestSignature> kagome::api::Session::on_request_
private

on request callback

Definition at line 110 of file session.hpp.


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