SNode.C
Loading...
Searching...
No Matches
core::socket::stream::SocketContext Class Referenceabstract

#include <SocketContext.h>

Inheritance diagram for core::socket::stream::SocketContext:
Collaboration diagram for core::socket::stream::SocketContext:

Public Member Functions

 SocketContext (core::socket::stream::SocketConnection *socketConnection)
 
void sendToPeer (const char *chunk, std::size_t chunkLen) const final
 
bool streamToPeer (core::pipe::Source *source) const
 
void streamEof ()
 
std::size_t readFromPeer (char *chunk, std::size_t chunklen) const final
 
void setTimeout (const utils::Timeval &timeout) final
 
void shutdownRead ()
 
void shutdownWrite (bool forceClose=false)
 
void close () override
 
SocketConnectiongetSocketConnection () const
 
virtual void switchSocketContext (SocketContext *newSocketContext)
 
void sendToPeer (const std::string &data) const
 
virtual void sendToPeer (const char *chunk, std::size_t chunkLen) const=0
 
- Public Member Functions inherited from core::socket::SocketContext
 SocketContext (const SocketContext &)=delete
 
 SocketContext (SocketContext &&)=delete
 
SocketContextoperator= (const SocketContext &)=delete
 
SocketContextoperator= (SocketContext &&)=delete
 
void sendToPeer (const std::string &data) const
 

Protected Member Functions

void onWriteError (int errnum) override
 
void onReadError (int errnum) override
 
- Protected Member Functions inherited from core::socket::SocketContext
 SocketContext ()=default
 
virtual ~SocketContext ()
 
virtual std::size_t onReceivedFromPeer ()=0
 
virtual bool onSignal (int sig)=0
 

Private Types

using Super = core::socket::SocketContext
 

Private Member Functions

virtual void onConnected ()=0
 
virtual void onDisconnected ()=0
 

Private Attributes

core::socket::stream::SocketConnectionsocketConnection
 

Friends

template<typename PhysicalSocketT , class SocketReaderT , class SocketWriterT >
class SocketConnectionT
 
class SocketConnection
 

Detailed Description

Definition at line 64 of file SocketContext.h.

Member Typedef Documentation

◆ Super

Constructor & Destructor Documentation

◆ SocketContext()

core::socket::stream::SocketContext::SocketContext ( core::socket::stream::SocketConnection socketConnection)
explicit

Definition at line 56 of file SocketContext.cpp.

58 }
core::socket::stream::SocketConnection * socketConnection

References socketConnection.

Referenced by apps::echo::model::EchoSocketContext::EchoSocketContext(), apps::http::SimpleSocketProtocol::SimpleSocketProtocol(), iot::mqtt_fast::SocketContext::SocketContext(), web::http::client::SocketContext::SocketContext(), web::http::server::SocketContext::SocketContext(), and iot::mqtt::SocketContext::SocketContext().

Here is the caller graph for this function:

Member Function Documentation

◆ close()

void core::socket::stream::SocketContext::close ( )
overridevirtual

Implements core::socket::SocketContext.

Reimplemented in iot::mqtt::SocketContext.

Definition at line 89 of file SocketContext.cpp.

References core::socket::stream::SocketConnection::close(), and socketConnection.

Referenced by iot::mqtt::SocketContext::close(), web::http::client::Request::executeUpgrade(), iot::mqtt_fast::SocketContext::onReceivedFromPeer(), web::http::client::Request::onSourceError(), web::http::server::Response::onSourceError(), and web::http::client::Request::upgrade().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSocketConnection()

SocketConnection * core::socket::stream::SocketContext::getSocketConnection ( ) const

Definition at line 65 of file SocketContext.cpp.

65 {
66 return socketConnection;
67 }

References socketConnection.

Referenced by web::http::server::SocketContext::deliverRequest(), web::http::client::SocketContext::deliverResponse(), web::http::client::SocketContext::deliverResponseParseError(), iot::mqtt::SocketContext::getSocketConnection(), web::http::client::SocketContext::initiateRequest(), web::http::client::SocketContext::onConnected(), web::http::server::SocketContext::onConnected(), web::http::client::SocketContext::onDisconnected(), web::http::server::SocketContext::onDisconnected(), web::http::client::SocketContext::onSignal(), web::http::server::SocketContext::onSignal(), web::http::server::SocketContext::requestCompleted(), web::http::client::SocketContext::requestDelivered(), web::http::client::SocketContext::requestPrepared(), web::http::server::SocketContext::responseCompleted(), web::http::client::SocketContext::responseDelivered(), web::http::client::Request::responseParseError(), web::http::client::SocketContext::responseStarted(), web::http::server::SocketContext::responseStarted(), web::http::client::SocketContext::SocketContext(), web::http::server::SocketContext::SocketContext(), express::middleware::StaticMiddleware::StaticMiddleware(), web::http::server::Response::upgrade(), web::http::client::Request::upgrade(), express::middleware::VerboseRequest::VerboseRequest(), and web::http::client::SocketContext::~SocketContext().

Here is the caller graph for this function:

◆ onConnected()

◆ onDisconnected()

◆ onReadError()

void core::socket::stream::SocketContext::onReadError ( int  errnum)
overrideprotectedvirtual

Implements core::socket::SocketContext.

Definition at line 108 of file SocketContext.cpp.

108 {
109 errno = errnum;
110
111 if (errno == 0) {
112 LOG(DEBUG) << socketConnection->getConnectionName() << " SocketContext: EOF received";
113 } else {
114 PLOG(DEBUG) << socketConnection->getConnectionName() << " SocketContext: onReadError";
115 }
117 }
const std::string & getConnectionName() const
void shutdownWrite(bool forceClose=false)

References core::socket::stream::SocketConnection::getConnectionName(), shutdownWrite(), and socketConnection.

Referenced by core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >::onReadError(), and apps::http::SimpleSocketProtocol::onReadError().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onWriteError()

void core::socket::stream::SocketContext::onWriteError ( int  errnum)
overrideprotectedvirtual

Implements core::socket::SocketContext.

Reimplemented in web::http::client::SocketContext, and web::http::server::SocketContext.

Definition at line 101 of file SocketContext.cpp.

101 {
102 errno = errnum;
103
104 PLOG(DEBUG) << socketConnection->getConnectionName() << " SocketContext: onWriteError";
105 shutdownRead();
106 }

References core::socket::stream::SocketConnection::getConnectionName(), shutdownRead(), and socketConnection.

Referenced by core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >::onWriteError(), and apps::http::SimpleSocketProtocol::onWriteError().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readFromPeer()

std::size_t core::socket::stream::SocketContext::readFromPeer ( char *  chunk,
std::size_t  chunklen 
) const
finalvirtual

Implements core::socket::SocketContext.

Definition at line 81 of file SocketContext.cpp.

81 {
82 return socketConnection->readFromPeer(chunk, chunklen);
83 }
virtual std::size_t readFromPeer(char *chunk, std::size_t chunkLen)=0

References core::socket::stream::SocketConnection::readFromPeer(), and socketConnection.

Referenced by apps::echo::model::EchoSocketContext::onReceivedFromPeer(), web::http::decoder::Fields::read(), web::http::decoder::HTTP10Response::read(), web::http::decoder::Identity::read(), web::http::decoder::Chunked::Chunk::read(), web::http::Parser::readStartLine(), and iot::mqtt::SocketContext::recv().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendToPeer() [1/3]

void core::socket::stream::SocketContext::sendToPeer ( const char *  chunk,
std::size_t  chunkLen 
) const
finalvirtual

Implements core::socket::SocketContext.

Definition at line 69 of file SocketContext.cpp.

69 {
70 socketConnection->sendToPeer(chunk, chunkLen);
71 }
virtual void sendToPeer(const char *chunk, std::size_t chunkLen)=0

References core::socket::stream::SocketConnection::sendToPeer(), and socketConnection.

Referenced by web::http::client::Request::executeSendFragment(), apps::echo::model::EchoSocketContext::onReceivedFromPeer(), iot::mqtt::SocketContext::send(), iot::mqtt_fast::SocketContext::send(), and web::http::server::Response::sendFragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendToPeer() [2/3]

virtual void core::socket::SocketContext::sendToPeer ( const char *  chunk,
std::size_t  chunkLen 
) const
virtual

◆ sendToPeer() [3/3]

void core::socket::SocketContext::sendToPeer ( const std::string &  data) const

Definition at line 75 of file SocketContext.cpp.

53 {
54 sendToPeer(data.data(), data.length());
55 }
void sendToPeer(const char *chunk, std::size_t chunkLen) const final

◆ setTimeout()

void core::socket::stream::SocketContext::setTimeout ( const utils::Timeval timeout)
finalvirtual

Implements core::socket::SocketContext.

Definition at line 85 of file SocketContext.cpp.

85 {
87 }
virtual void setTimeout(const utils::Timeval &timeout)=0

References core::socket::stream::SocketConnection::setTimeout(), and socketConnection.

Here is the call graph for this function:

◆ shutdownRead()

void core::socket::stream::SocketContext::shutdownRead ( )

Definition at line 93 of file SocketContext.cpp.

References core::socket::stream::SocketConnection::shutdownRead(), and socketConnection.

Referenced by apps::http::SimpleSocketProtocol::onWriteError(), and onWriteError().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdownWrite()

void core::socket::stream::SocketContext::shutdownWrite ( bool  forceClose = false)

Definition at line 97 of file SocketContext.cpp.

97 {
99 }
virtual void shutdownWrite(bool forceClose)=0

References core::socket::stream::SocketConnection::shutdownWrite(), and socketConnection.

Referenced by web::http::client::SocketContext::deliverResponseParseError(), iot::mqtt::SocketContext::end(), apps::http::SimpleSocketProtocol::onReadError(), onReadError(), web::http::server::SocketContext::requestCompleted(), web::http::client::SocketContext::requestDelivered(), web::http::server::SocketContext::responseCompleted(), and web::http::client::SocketContext::responseStarted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ streamEof()

void core::socket::stream::SocketContext::streamEof ( )

Definition at line 77 of file SocketContext.cpp.

References socketConnection, and core::socket::stream::SocketConnection::streamEof().

Referenced by web::http::client::Request::onSourceEof(), web::http::server::Response::onSourceEof(), web::http::client::Request::onSourceError(), web::http::server::Response::onSourceError(), web::http::client::Request::~Request(), and web::http::server::Response::~Response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ streamToPeer()

bool core::socket::stream::SocketContext::streamToPeer ( core::pipe::Source source) const

Definition at line 73 of file SocketContext.cpp.

73 {
74 return socketConnection->streamToPeer(source);
75 }
virtual bool streamToPeer(core::pipe::Source *source)=0

References socketConnection, and core::socket::stream::SocketConnection::streamToPeer().

Referenced by web::http::client::Request::onSourceConnect(), and web::http::server::Response::onSourceConnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ switchSocketContext()

void core::socket::stream::SocketContext::switchSocketContext ( SocketContext newSocketContext)
virtual

Definition at line 60 of file SocketContext.cpp.

60 {
61 LOG(DEBUG) << socketConnection->getConnectionName() << ": Register new SocketContext";
62 socketConnection->switchSocketContext(newSocketContext);
63 }
void switchSocketContext(SocketContext *newSocketContext)

References core::socket::stream::SocketConnection::getConnectionName(), socketConnection, and core::socket::stream::SocketConnection::switchSocketContext().

Referenced by web::http::server::Response::sendCompleted(), and web::http::client::Request::upgrade().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ SocketConnection

friend class SocketConnection
friend

Definition at line 100 of file SocketContext.h.

◆ SocketConnectionT

template<typename PhysicalSocketT , class SocketReaderT , class SocketWriterT >
friend class SocketConnectionT
friend

Definition at line 99 of file SocketContext.h.

Member Data Documentation

◆ socketConnection


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