Electroneum
Loading...
Searching...
No Matches
epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t > Struct Template Reference

#include <levin_protocol_handler_async.h>

Inheritance diagram for epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >:
Collaboration diagram for epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >:

Public Member Functions

 anvoke_handler (const callback_t &cb, uint64_t timeout, async_protocol_handler &con, int command)
virtual ~anvoke_handler ()
virtual bool handle (int res, const epee::span< const uint8_t > buff, typename async_protocol_handler::connection_context &context)
virtual bool is_timer_started () const
virtual void cancel ()
virtual bool cancel_timer ()
virtual void reset_timer ()

Public Attributes

callback_t m_cb
async_protocol_handlerm_con
boost::asio::deadline_timer m_timer
bool m_timer_started
bool m_cancel_timer_called
bool m_timer_cancelled
uint64_t m_timeout
int m_command

Detailed Description

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
struct epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >

Definition at line 162 of file levin_protocol_handler_async.h.

Constructor & Destructor Documentation

◆ anvoke_handler()

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::anvoke_handler ( const callback_t & cb,
uint64_t timeout,
async_protocol_handler & con,
int command )
inline

Definition at line 164 of file levin_protocol_handler_async.h.

167 {
168 if(m_con.start_outer_call())
169 {
170 MDEBUG(con.get_context_ref() << "anvoke_handler, timeout: " << timeout);
172 m_timer.async_wait([&con, command, cb, timeout](const boost::system::error_code& ec)
173 {
175 return;
176 MINFO(con.get_context_ref() << "Timeout on invoke operation happened, command: " << command << " timeout: " << timeout);
179 con.close();
181 });
182 m_timer_started = true;
183 }
184 }
net_utils::i_service_endpoint * m_pservice_endpoint
#define MDEBUG(x)
Definition misc_log_ex.h:76
#define MINFO(x)
Definition misc_log_ex.h:75
virtual boost::asio::io_service & get_io_service()=0
Here is the call graph for this function:

◆ ~anvoke_handler()

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
virtual epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::~anvoke_handler ( )
inlinevirtual

Definition at line 185 of file levin_protocol_handler_async.h.

186 {}

Member Function Documentation

◆ cancel()

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
virtual void epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::cancel ( )
inlinevirtual

Implements epee::levin::async_protocol_handler< t_connection_context >::invoke_response_handler_base.

Definition at line 207 of file levin_protocol_handler_async.h.

208 {
209 if(cancel_timer())
210 {
212 m_cb(LEVIN_ERROR_CONNECTION_DESTROYED, fake, m_con.get_context_ref());
213 m_con.finish_outer_call();
214 }
215 }
Here is the call graph for this function:

◆ cancel_timer()

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
virtual bool epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::cancel_timer ( )
inlinevirtual

Implements epee::levin::async_protocol_handler< t_connection_context >::invoke_response_handler_base.

Definition at line 216 of file levin_protocol_handler_async.h.

217 {
219 {
222 m_timer_cancelled = 1 == m_timer.cancel(ignored_ec);
223 }
224 return m_timer_cancelled;
225 }
Here is the caller graph for this function:

◆ handle()

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
virtual bool epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::handle ( int res,
const epee::span< const uint8_t > buff,
typename async_protocol_handler::connection_context & context )
inlinevirtual

Implements epee::levin::async_protocol_handler< t_connection_context >::invoke_response_handler_base.

Definition at line 195 of file levin_protocol_handler_async.h.

196 {
197 if(!cancel_timer())
198 return false;
199 m_cb(res, buff, context);
200 m_con.finish_outer_call();
201 return true;
202 }
Here is the call graph for this function:

◆ is_timer_started()

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
virtual bool epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::is_timer_started ( ) const
inlinevirtual

◆ reset_timer()

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
virtual void epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::reset_timer ( )
inlinevirtual

Implements epee::levin::async_protocol_handler< t_connection_context >::invoke_response_handler_base.

Definition at line 226 of file levin_protocol_handler_async.h.

227 {
229 if (!m_cancel_timer_called && m_timer.cancel(ignored_ec) > 0)
230 {
231 callback_t& cb = m_cb;
234 int command = m_command;
236 m_timer.async_wait([&con, cb, command, timeout](const boost::system::error_code& ec)
237 {
239 return;
240 MINFO(con.get_context_ref() << "Timeout on invoke operation happened, command: " << command << " timeout: " << timeout);
243 con.close();
245 });
246 }
247 }
Here is the call graph for this function:

Member Data Documentation

◆ m_cancel_timer_called

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
bool epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::m_cancel_timer_called

Definition at line 191 of file levin_protocol_handler_async.h.

◆ m_cb

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
callback_t epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::m_cb

Definition at line 187 of file levin_protocol_handler_async.h.

◆ m_command

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
int epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::m_command

Definition at line 194 of file levin_protocol_handler_async.h.

◆ m_con

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
async_protocol_handler& epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::m_con

Definition at line 188 of file levin_protocol_handler_async.h.

◆ m_timeout

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
uint64_t epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::m_timeout

Definition at line 193 of file levin_protocol_handler_async.h.

◆ m_timer

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
boost::asio::deadline_timer epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::m_timer

Definition at line 189 of file levin_protocol_handler_async.h.

◆ m_timer_cancelled

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
bool epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::m_timer_cancelled

Definition at line 192 of file levin_protocol_handler_async.h.

◆ m_timer_started

template<class t_connection_context = net_utils::connection_context_base>
template<class callback_t>
bool epee::levin::async_protocol_handler< t_connection_context >::anvoke_handler< callback_t >::m_timer_started

Definition at line 190 of file levin_protocol_handler_async.h.


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