#include <swcdb/core/comm/ConnHandler.h>
Classes | |
struct | Outgoing |
struct | Pending |
struct | PendingHash |
struct | Receiver_Buffer |
struct | Receiver_Header |
struct | Receiver_HeaderPrefix |
struct | Sender_Ack |
struct | Sender_noAck |
Public Member Functions | |
ConnHandler (const ConnHandler &)=delete | |
ConnHandler (ConnHandler &&)=delete | |
ConnHandler & | operator= (const ConnHandler &)=delete |
ConnHandler & | operator= (ConnHandler &&)=delete |
SWC_CAN_INLINE size_t | endpoint_remote_hash () const noexcept |
SWC_CAN_INLINE size_t | endpoint_local_hash () const noexcept |
SWC_CAN_INLINE Core::Encoder::Type | get_encoder () const noexcept |
virtual bool | is_secure () const noexcept |
void | new_connection () |
virtual bool | is_open () const noexcept=0 |
size_t | pending_read () noexcept |
SWC_CAN_INLINE bool | due () |
virtual void | do_close () noexcept=0 |
bool | send_error (int error, const std::string &msg, const Event::Ptr &ev) noexcept |
bool | response_ok (const Event::Ptr &ev) noexcept |
bool | send_response (Buffers::Ptr cbuf, DispatchHandler::Ptr hdlr=nullptr) noexcept |
bool | send_request (Buffers::Ptr cbuf, DispatchHandler::Ptr hdlr) |
void | print (std::ostream &out) const |
Public Attributes | |
Core::AtomicBool | connected |
const AppContext::Ptr | app_ctx |
EndPoint | endpoint_remote |
EndPoint | endpoint_local |
Protected Member Functions | |
SWC_CAN_INLINE | ConnHandler (AppContext::Ptr &a_app_ctx) noexcept |
SWC_CAN_INLINE ConnHandlerPtr | ptr () noexcept |
virtual | ~ConnHandler () noexcept |
virtual SocketLayer * | socket_layer () noexcept=0 |
virtual void | read (uint8_t **bufp, size_t *remainp, asio::error_code &ec)=0 |
virtual void | do_async_write (Core::Vector< asio::const_buffer > &&buffers, Sender_noAck &&hdlr) noexcept=0 |
virtual void | do_async_write (Core::Vector< asio::const_buffer > &&buffers, Sender_Ack &&hdlr) noexcept=0 |
virtual void | do_async_read (uint8_t *data, uint32_t sz, Receiver_HeaderPrefix &&hdlr) noexcept=0 |
virtual void | do_async_read (uint8_t *data, uint32_t sz, Receiver_Header &&hdlr) noexcept=0 |
virtual void | do_async_read (uint8_t *data, uint32_t sz, Receiver_Buffer &&hdlr) noexcept=0 |
void | do_close_run () noexcept |
void | disconnected () noexcept |
Protected Attributes | |
Core::MutexSptd | m_mutex |
Private Member Functions | |
void | write_or_queue (Outgoing &&outgoing) |
void | write_next () |
void | write (Outgoing &outgoing) |
void | read () noexcept |
void | recv_buffers (Event::Ptr &&ev) |
void | received (Event::Ptr &&ev) noexcept |
SWC_CAN_INLINE void | do_close_recv () noexcept |
void | run_pending (Event::Ptr &&ev) |
Private Attributes | |
uint32_t | m_next_req_id |
Core::QueueSafeStated< Outgoing > | m_outgoing |
std::unordered_map< uint32_t, Pending, PendingHash > | m_pending |
size_t | m_recv_bytes |
uint8_t | _buf_header [Header::MAX_LENGTH] |
Definition at line 29 of file ConnHandler.h.
|
delete |
|
delete |
|
inlineprotectednoexcept |
Definition at line 162 of file ConnHandler.h.
|
inlineprotectedvirtualnoexcept |
Definition at line 174 of file ConnHandler.h.
|
protectednoexcept |
Definition at line 459 of file ConnHandler.cc.
References SWC::LOG_ERROR, m_mutex, m_outgoing, m_pending, print(), SWC_CURRENT_EXCEPTION, SWC_LOG_OSTREAM, and SWC_LOG_OUT.
Referenced by SWC::Comm::ConnHandlerPlain::do_close(), and SWC::Comm::ConnHandlerSSL::do_close().
|
protectedpure virtualnoexcept |
Implemented in SWC::Comm::ConnHandlerSSL, and SWC::Comm::ConnHandlerPlain.
|
protectedpure virtualnoexcept |
Implemented in SWC::Comm::ConnHandlerSSL, and SWC::Comm::ConnHandlerPlain.
|
protectedpure virtualnoexcept |
Implemented in SWC::Comm::ConnHandlerSSL, and SWC::Comm::ConnHandlerPlain.
Referenced by read(), and recv_buffers().
|
protectedpure virtualnoexcept |
Implemented in SWC::Comm::ConnHandlerSSL, and SWC::Comm::ConnHandlerPlain.
|
protectedpure virtualnoexcept |
Implemented in SWC::Comm::ConnHandlerSSL, and SWC::Comm::ConnHandlerPlain.
Referenced by write().
|
pure virtualnoexcept |
Implemented in SWC::Comm::ConnHandlerSSL, and SWC::Comm::ConnHandlerPlain.
Referenced by do_close_recv(), and write().
|
inlineprivatenoexcept |
Definition at line 225 of file ConnHandler.h.
References app_ctx, do_close(), m_recv_bytes, and ptr().
|
protectednoexcept |
Definition at line 32 of file ConnHandler.cc.
References app_ctx, and ptr().
Referenced by SWC::Comm::ConnHandlerPlain::do_close(), and SWC::Comm::ConnHandlerSSL::do_close().
|
inline |
Definition at line 141 of file ConnHandler.h.
References m_outgoing, and pending_read().
|
inlinenoexcept |
Definition at line 120 of file ConnHandler.h.
References SWC::Comm::endpoint_hash(), and endpoint_local.
|
inlinenoexcept |
Definition at line 115 of file ConnHandler.h.
References SWC::Comm::endpoint_hash(), and endpoint_remote.
|
inlinenoexcept |
Definition at line 125 of file ConnHandler.h.
References app_ctx, endpoint_local, and endpoint_remote.
Referenced by print(), and write_or_queue().
|
pure virtualnoexcept |
Implemented in SWC::Comm::ConnHandlerSSL, and SWC::Comm::ConnHandlerPlain.
Referenced by print().
|
inlinevirtualnoexcept |
Reimplemented in SWC::Comm::ConnHandlerSSL.
Definition at line 132 of file ConnHandler.h.
Referenced by print().
void SWC::Comm::ConnHandler::new_connection | ( | ) |
Definition at line 16 of file ConnHandler.cc.
References app_ctx, endpoint_local, endpoint_remote, SWC::LOG_DEBUG, print(), ptr(), read(), socket_layer(), SWC_LOG_OSTREAM, and SWC_LOG_OUT.
|
delete |
|
delete |
|
noexcept |
Definition at line 27 of file ConnHandler.cc.
References m_mutex, and m_pending.
Referenced by due().
void SWC::Comm::ConnHandler::print | ( | std::ostream & | out | ) | const |
Definition at line 69 of file ConnHandler.cc.
References endpoint_local, endpoint_remote, get_encoder(), is_open(), is_secure(), and SWC::Core::Encoder::to_string().
Referenced by disconnected(), and new_connection().
|
inlineprotectednoexcept |
Definition at line 170 of file ConnHandler.h.
Referenced by do_close_recv(), do_close_run(), new_connection(), read(), recv_buffers(), run_pending(), and write().
|
privatenoexcept |
Definition at line 411 of file ConnHandler.cc.
References _buf_header, connected, do_async_read(), m_recv_bytes, SWC::Comm::Header::PREFIX_LENGTH, and ptr().
Referenced by new_connection(), SWC::Comm::ConnHandlerPlain::read(), and SWC::Comm::ConnHandlerSSL::read().
|
protectedpure virtual |
Implemented in SWC::Comm::ConnHandlerSSL, and SWC::Comm::ConnHandlerPlain.
|
privatenoexcept |
Definition at line 438 of file ConnHandler.cc.
References SWC::Comm::Header::FLAG_REQUEST_BIT, SWC::LOG_ERROR, SWC::Comm::print(), SWC::Common::Files::RgrData::read(), SWC_CURRENT_EXCEPTION, SWC_LOG_OSTREAM, and SWC_LOG_OUT.
|
private |
Definition at line 421 of file ConnHandler.cc.
References SWC::Core::Buffer< T >::base, do_async_read(), ptr(), SWC::Core::Buffer< T >::reallocate(), and SWC::Core::Buffer< T >::size.
|
noexcept |
Definition at line 45 of file ConnHandler.cc.
References SWC::Comm::Buffers::make(), and SWC::Error::OK.
|
private |
Definition at line 489 of file ConnHandler.cc.
References app_ctx, SWC::Comm::Header::FLAG_REQUEST_BIT, SWC::Comm::Header::FLAG_RESPONSE_PARTIAL_BIT, SWC::Comm::ConnHandler::Pending::hdlr, m_mutex, m_pending, operator=(), ptr(), socket_layer(), SWC_CAN_INLINE, and SWC::Comm::ConnHandler::Pending::timer.
|
noexcept |
Definition at line 36 of file ConnHandler.cc.
References SWC::Comm::Buffers::create_error_message().
bool SWC::Comm::ConnHandler::send_request | ( | Buffers::Ptr | cbuf, |
DispatchHandler::Ptr | hdlr | ||
) |
Definition at line 60 of file ConnHandler.cc.
References connected, SWC::Comm::Header::FLAG_REQUEST_BIT, and write_or_queue().
|
noexcept |
Definition at line 51 of file ConnHandler.cc.
References SWC::Comm::Header::FLAG_REQUEST_MASK.
|
protectedpure virtualnoexcept |
Implemented in SWC::Comm::ConnHandlerSSL, and SWC::Comm::ConnHandlerPlain.
Referenced by new_connection(), run_pending(), and write().
|
private |
Definition at line 162 of file ConnHandler.cc.
References SWC::Comm::Protocol::Rgr::Handler::assign_id(), SWC::Comm::ConnHandler::Outgoing::cbuf, connected, do_async_write(), do_close(), SWC::Comm::Header::FLAG_REQUEST_BIT, SWC::Comm::Header::FLAG_REQUEST_MASK, SWC::Comm::Header::FLAG_RESPONSE_IGNORE_BIT, SWC::Comm::ConnHandler::Outgoing::hdlr, m_mutex, m_next_req_id, m_pending, SWC::Comm::Event::make(), operator=(), ptr(), SWC::Error::REQUEST_TIMEOUT, socket_layer(), SWC_CAN_INLINE, and write_next().
Referenced by write_next(), and write_or_queue().
|
private |
Definition at line 86 of file ConnHandler.cc.
References m_outgoing, and write().
Referenced by write().
|
private |
Definition at line 79 of file ConnHandler.cc.
References get_encoder(), m_outgoing, and write().
Referenced by send_request().
|
private |
Definition at line 246 of file ConnHandler.h.
Referenced by read().
const AppContext::Ptr SWC::Comm::ConnHandler::app_ctx |
Definition at line 110 of file ConnHandler.h.
Referenced by do_close_recv(), do_close_run(), get_encoder(), SWC::Comm::ConnHandlerSSL::make(), SWC::Comm::ConnHandlerPlain::make(), new_connection(), and run_pending().
Core::AtomicBool SWC::Comm::ConnHandler::connected |
Definition at line 109 of file ConnHandler.h.
Referenced by SWC::Comm::ConnHandlerPlain::do_close(), SWC::Comm::ConnHandlerSSL::do_close(), SWC::Comm::ConnHandlerPlain::is_open(), SWC::Comm::ConnHandlerSSL::is_open(), read(), send_request(), and write().
EndPoint SWC::Comm::ConnHandler::endpoint_local |
Definition at line 112 of file ConnHandler.h.
Referenced by endpoint_local_hash(), get_encoder(), new_connection(), and print().
EndPoint SWC::Comm::ConnHandler::endpoint_remote |
Definition at line 111 of file ConnHandler.h.
Referenced by endpoint_remote_hash(), get_encoder(), new_connection(), and print().
|
protected |
Definition at line 208 of file ConnHandler.h.
Referenced by disconnected(), pending_read(), run_pending(), and write().
|
private |
Definition at line 240 of file ConnHandler.h.
Referenced by write().
|
private |
Definition at line 241 of file ConnHandler.h.
Referenced by disconnected(), due(), write_next(), and write_or_queue().
|
private |
Definition at line 244 of file ConnHandler.h.
Referenced by disconnected(), pending_read(), run_pending(), and write().
|
private |
Definition at line 245 of file ConnHandler.h.
Referenced by do_close_recv(), and read().