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
 
- 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

Referenced by 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.

Referenced by iot::mqtt::SocketContext::close().

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 }

Referenced by iot::mqtt::SocketContext::getSocketConnection().

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)

◆ 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 }

◆ 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

Referenced by web::http::decoder::Chunked::Chunk::read(), web::http::decoder::Fields::read(), web::http::decoder::HTTP10Response::read(), and iot::mqtt::SocketContext::recv().

Here is the caller graph for this function:

◆ sendToPeer() [1/2]

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

Referenced by iot::mqtt::SocketContext::send().

Here is the caller graph for this function:

◆ sendToPeer() [2/2]

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

◆ shutdownRead()

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

Definition at line 93 of file SocketContext.cpp.

◆ 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

Referenced by iot::mqtt::SocketContext::end().

Here is the caller graph for this function:

◆ streamEof()

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

Definition at line 77 of file SocketContext.cpp.

◆ 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

◆ 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)

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

core::socket::stream::SocketConnection* core::socket::stream::SocketContext::socketConnection
private

Definition at line 96 of file SocketContext.h.


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