Electroneum
epee::jsonrpc_server_impl_base< t_child_class, t_connection_context > Class Template Reference

#include <jsonrpc_server_impl_base.h>

Inheritance diagram for epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >:
Collaboration diagram for epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >:

Public Member Functions

 jsonrpc_server_impl_base ()
 
 jsonrpc_server_impl_base (boost::asio::io_service &external_io_service)
 
bool init (const std::string &bind_port="0", const std::string &bind_ip="0.0.0.0")
 
bool run (size_t threads_count, bool wait=true)
 
bool deinit ()
 
bool timed_wait_server_stop (uint64_t ms)
 
bool send_stop_signal ()
 
int get_binded_port ()
 
- Public Member Functions inherited from epee::net_utils::jsonrpc2::i_jsonrpc2_server_handler< t_connection_context >
virtual ~i_jsonrpc2_server_handler ()
 
virtual bool handle_rpc_request (const std::string &req_data, std::string &resp_data, t_connection_context &conn_context)=0
 
virtual bool init_server_thread ()
 
virtual bool deinit_server_thread ()
 

Protected Attributes

net_utils::boosted_tcp_server< net_utils::jsonrpc2::jsonrpc2_connection_handler< t_connection_context > > m_net_server
 

Detailed Description

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
class epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >

Definition at line 15 of file jsonrpc_server_impl_base.h.

Constructor & Destructor Documentation

◆ jsonrpc_server_impl_base() [1/2]

template<class t_child_class , class t_connection_context = epee::net_utils::connection_context_base>
epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >::jsonrpc_server_impl_base ( )
inline

Definition at line 19 of file jsonrpc_server_impl_base.h.

20  : m_net_server()
21  {}
net_utils::boosted_tcp_server< net_utils::jsonrpc2::jsonrpc2_connection_handler< t_connection_context > > m_net_server

◆ jsonrpc_server_impl_base() [2/2]

template<class t_child_class , class t_connection_context = epee::net_utils::connection_context_base>
epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >::jsonrpc_server_impl_base ( boost::asio::io_service &  external_io_service)
inlineexplicit

Definition at line 23 of file jsonrpc_server_impl_base.h.

24  : m_net_server(external_io_service)
25  {}
net_utils::boosted_tcp_server< net_utils::jsonrpc2::jsonrpc2_connection_handler< t_connection_context > > m_net_server

Member Function Documentation

◆ deinit()

template<class t_child_class , class t_connection_context = epee::net_utils::connection_context_base>
bool epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >::deinit ( )
inline

Definition at line 56 of file jsonrpc_server_impl_base.h.

57  {
58  return m_net_server.deinit_server();
59  }
net_utils::boosted_tcp_server< net_utils::jsonrpc2::jsonrpc2_connection_handler< t_connection_context > > m_net_server

◆ get_binded_port()

template<class t_child_class , class t_connection_context = epee::net_utils::connection_context_base>
int epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >::get_binded_port ( )
inline

Definition at line 72 of file jsonrpc_server_impl_base.h.

73  {
74  return m_net_server.get_binded_port();
75  }
net_utils::boosted_tcp_server< net_utils::jsonrpc2::jsonrpc2_connection_handler< t_connection_context > > m_net_server

◆ init()

template<class t_child_class , class t_connection_context = epee::net_utils::connection_context_base>
bool epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >::init ( const std::string &  bind_port = "0",
const std::string &  bind_ip = "0.0.0.0" 
)
inline

Definition at line 27 of file jsonrpc_server_impl_base.h.

28  {
29  //set self as callback handler
30  m_net_server.get_config_object().m_phandler = static_cast<t_child_class*>(this);
31 
32  LOG_PRINT_L0("Binding on " << bind_ip << ":" << bind_port);
33  bool res = m_net_server.init_server(bind_port, bind_ip);
34  if (!res)
35  {
36  LOG_ERROR("Failed to bind server");
37  return false;
38  }
39  return true;
40  }
const char * res
Definition: hmac_keccak.cpp:41
#define LOG_PRINT_L0(x)
Definition: misc_log_ex.h:99
net_utils::boosted_tcp_server< net_utils::jsonrpc2::jsonrpc2_connection_handler< t_connection_context > > m_net_server
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98

◆ run()

template<class t_child_class , class t_connection_context = epee::net_utils::connection_context_base>
bool epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >::run ( size_t  threads_count,
bool  wait = true 
)
inline

Definition at line 42 of file jsonrpc_server_impl_base.h.

43  {
44  //go to loop
45  LOG_PRINT("Run net_service loop( " << threads_count << " threads)...", LOG_LEVEL_0);
46  if(!m_net_server.run_server(threads_count, wait))
47  {
48  LOG_ERROR("Failed to run net tcp server!");
49  }
50 
51  if(wait)
52  LOG_PRINT("net_service loop stopped.", LOG_LEVEL_0);
53  return true;
54  }
net_utils::boosted_tcp_server< net_utils::jsonrpc2::jsonrpc2_connection_handler< t_connection_context > > m_net_server
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98

◆ send_stop_signal()

template<class t_child_class , class t_connection_context = epee::net_utils::connection_context_base>
bool epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >::send_stop_signal ( )
inline

Definition at line 66 of file jsonrpc_server_impl_base.h.

67  {
68  m_net_server.send_stop_signal();
69  return true;
70  }
net_utils::boosted_tcp_server< net_utils::jsonrpc2::jsonrpc2_connection_handler< t_connection_context > > m_net_server

◆ timed_wait_server_stop()

template<class t_child_class , class t_connection_context = epee::net_utils::connection_context_base>
bool epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >::timed_wait_server_stop ( uint64_t  ms)
inline

Definition at line 61 of file jsonrpc_server_impl_base.h.

62  {
63  return m_net_server.timed_wait_server_stop(ms);
64  }
net_utils::boosted_tcp_server< net_utils::jsonrpc2::jsonrpc2_connection_handler< t_connection_context > > m_net_server

Member Data Documentation

◆ m_net_server

template<class t_child_class , class t_connection_context = epee::net_utils::connection_context_base>
net_utils::boosted_tcp_server<net_utils::jsonrpc2::jsonrpc2_connection_handler<t_connection_context> > epee::jsonrpc_server_impl_base< t_child_class, t_connection_context >::m_net_server
protected

Definition at line 78 of file jsonrpc_server_impl_base.h.


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