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

#include <SocketConnection.h>

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

Public Member Functions

 SocketConnection (const std::string &instanceName, int fd, const std::string &configuredServer)
 
virtual int getFd () const =0
 
void switchSocketContext (SocketContext *newSocketContext)
 
virtual void sendToPeer (const char *chunk, std::size_t chunkLen)=0
 
void sendToPeer (const std::string &data)
 
void sentToPeer (const std::vector< uint8_t > &data)
 
void sentToPeer (const std::vector< char > &data)
 
virtual bool streamToPeer (core::pipe::Source *source)=0
 
virtual void streamEof ()=0
 
virtual std::size_t readFromPeer (char *chunk, std::size_t chunkLen)=0
 
virtual void shutdownRead ()=0
 
virtual void shutdownWrite (bool forceClose)=0
 
const std::string & getInstanceName () const
 
const std::string & getConnectionName () const
 
const std::string & getConfiguredServer () const
 
virtual const core::socket::SocketAddressgetLocalAddress () const =0
 
virtual const core::socket::SocketAddressgetRemoteAddress () const =0
 
virtual void close ()=0
 
virtual void setTimeout (const utils::Timeval &timeout)=0
 

Protected Member Functions

virtual ~SocketConnection ()
 
void setSocketContext (SocketContext *socketContext)
 
void connectSocketContext (const std::shared_ptr< SocketContextFactory > &socketContextFactory)
 
void disconnectCurrentSocketContext ()
 

Protected Attributes

core::socket::stream::SocketContextsocketContext = nullptr
 
core::socket::stream::SocketContextnewSocketContext = nullptr
 
std::string instanceName
 
std::string connectionName
 
std::string configuredServer
 

Detailed Description

Definition at line 75 of file SocketConnection.h.

Constructor & Destructor Documentation

◆ SocketConnection()

core::socket::stream::SocketConnection::SocketConnection ( const std::string &  instanceName,
int  fd,
const std::string &  configuredServer 
)

◆ ~SocketConnection()

core::socket::stream::SocketConnection::~SocketConnection ( )
protectedvirtual

Definition at line 61 of file SocketConnection.cpp.

61 {
62 }

Member Function Documentation

◆ close()

virtual void core::socket::stream::SocketConnection::close ( )
pure virtual

Implemented in core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >.

Referenced by core::socket::stream::SocketContext::close(), and connectSocketContext().

Here is the caller graph for this function:

◆ connectSocketContext()

void core::socket::stream::SocketConnection::connectSocketContext ( const std::shared_ptr< SocketContextFactory > &  socketContextFactory)
protected

Definition at line 102 of file SocketConnection.cpp.

102 {
103 SocketContext* socketContext = socketContextFactory->create(this);
104
105 if (socketContext != nullptr) {
106 LOG(DEBUG) << connectionName << ": Creating SocketContext successful";
108 } else {
109 LOG(ERROR) << connectionName << ": Failed creating SocketContext";
110 close();
111 }
112 }
core::socket::stream::SocketContext * socketContext
void setSocketContext(SocketContext *socketContext)

References close(), connectionName, core::socket::stream::SocketContextFactory::create(), and setSocketContext().

Here is the call graph for this function:

◆ disconnectCurrentSocketContext()

void core::socket::stream::SocketConnection::disconnectCurrentSocketContext ( )
protected

Definition at line 114 of file SocketConnection.cpp.

114 {
115 if (socketContext != nullptr) {
117 delete socketContext;
118
119 LOG(DEBUG) << connectionName << ": SocketContext disconnected";
120 }
121 }

References connectionName, core::socket::stream::SocketContext::onDisconnected(), and socketContext.

Referenced by core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >::onReceivedFromPeer(), and core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >::unobservedEvent().

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

◆ getConfiguredServer()

const std::string & core::socket::stream::SocketConnection::getConfiguredServer ( ) const

Definition at line 98 of file SocketConnection.cpp.

98 {
99 return configuredServer;
100 }

References configuredServer.

Referenced by web::http::client::SocketContext::SocketContext().

Here is the caller graph for this function:

◆ getConnectionName()

const std::string & core::socket::stream::SocketConnection::getConnectionName ( ) const

Definition at line 94 of file SocketConnection.cpp.

94 {
95 return connectionName;
96 }

References connectionName.

Referenced by web::http::server::SocketContext::deliverRequest(), web::http::client::SocketContext::deliverResponse(), web::http::client::SocketContext::deliverResponseParseError(), 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::websocket::SubProtocol< SocketContextUpgradeT >::onPongReceived(), core::socket::stream::SocketContext::onReadError(), web::http::client::SocketContext::onSignal(), web::http::server::SocketContext::onSignal(), core::socket::stream::SocketContext::onWriteError(), 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::server::SocketContext::SocketContext(), express::middleware::StaticMiddleware::StaticMiddleware(), core::socket::stream::SocketContext::switchSocketContext(), 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:

◆ getFd()

virtual int core::socket::stream::SocketConnection::getFd ( ) const
pure virtual

◆ getInstanceName()

const std::string & core::socket::stream::SocketConnection::getInstanceName ( ) const

Definition at line 90 of file SocketConnection.cpp.

90 {
91 return instanceName;
92 }

References instanceName.

◆ getLocalAddress()

virtual const core::socket::SocketAddress & core::socket::stream::SocketConnection::getLocalAddress ( ) const
pure virtual

◆ getRemoteAddress()

virtual const core::socket::SocketAddress & core::socket::stream::SocketConnection::getRemoteAddress ( ) const
pure virtual

◆ readFromPeer()

virtual std::size_t core::socket::stream::SocketConnection::readFromPeer ( char *  chunk,
std::size_t  chunkLen 
)
pure virtual

Implemented in core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >.

Referenced by web::websocket::Receiver::readFrameData(), and core::socket::stream::SocketContext::readFromPeer().

Here is the caller graph for this function:

◆ sendToPeer() [1/2]

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

◆ sendToPeer() [2/2]

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

Definition at line 78 of file SocketConnection.cpp.

78 {
79 sendToPeer(data.data(), data.size());
80 }
virtual void sendToPeer(const char *chunk, std::size_t chunkLen)=0

References sendToPeer().

Referenced by tls::getClient(), and legacy::getLegacyClient().

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

◆ sentToPeer() [1/2]

void core::socket::stream::SocketConnection::sentToPeer ( const std::vector< char > &  data)

Definition at line 86 of file SocketConnection.cpp.

86 {
87 sendToPeer(data.data(), data.size());
88 }

References sendToPeer().

Here is the call graph for this function:

◆ sentToPeer() [2/2]

void core::socket::stream::SocketConnection::sentToPeer ( const std::vector< uint8_t > &  data)

Definition at line 82 of file SocketConnection.cpp.

82 {
83 sendToPeer(reinterpret_cast<const char*>(data.data()), data.size());
84 }

References sendToPeer().

Here is the call graph for this function:

◆ setSocketContext()

void core::socket::stream::SocketConnection::setSocketContext ( SocketContext socketContext)
protected

Definition at line 68 of file SocketConnection.cpp.

68 {
69 if (socketContext != nullptr) { // Perform a pending SocketContextSwitch
70 LOG(DEBUG) << connectionName << ": Connecting SocketContext";
73 } else {
74 LOG(ERROR) << connectionName << ": Connecting SocketContext failed: no new SocketContext";
75 }
76 }

References connectionName, core::socket::stream::SocketContext::onConnected(), and socketContext.

Referenced by connectSocketContext(), and core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >::onReceivedFromPeer().

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

◆ setTimeout()

virtual void core::socket::stream::SocketConnection::setTimeout ( const utils::Timeval timeout)
pure virtual

Implemented in core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >.

Referenced by iot::mqtt::Mqtt::initSession(), and core::socket::stream::SocketContext::setTimeout().

Here is the caller graph for this function:

◆ shutdownRead()

virtual void core::socket::stream::SocketConnection::shutdownRead ( )
pure virtual

Implemented in core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >.

Referenced by core::socket::stream::SocketContext::shutdownRead().

Here is the caller graph for this function:

◆ shutdownWrite()

virtual void core::socket::stream::SocketConnection::shutdownWrite ( bool  forceClose)
pure virtual

Implemented in core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >.

Referenced by core::socket::stream::SocketContext::shutdownWrite().

Here is the caller graph for this function:

◆ streamEof()

virtual void core::socket::stream::SocketConnection::streamEof ( )
pure virtual

Implemented in core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >.

Referenced by core::socket::stream::SocketContext::streamEof().

Here is the caller graph for this function:

◆ streamToPeer()

virtual bool core::socket::stream::SocketConnection::streamToPeer ( core::pipe::Source source)
pure virtual

Implemented in core::socket::stream::SocketConnectionT< PhysicalSocketT, SocketReaderT, SocketWriterT >.

Referenced by core::socket::stream::SocketContext::streamToPeer().

Here is the caller graph for this function:

◆ switchSocketContext()

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

Definition at line 64 of file SocketConnection.cpp.

64 {
66 }
core::socket::stream::SocketContext * newSocketContext

References newSocketContext.

Referenced by core::socket::stream::SocketContext::switchSocketContext().

Here is the caller graph for this function:

Member Data Documentation

◆ configuredServer

std::string core::socket::stream::SocketConnection::configuredServer
protected

Definition at line 125 of file SocketConnection.h.

Referenced by getConfiguredServer(), and SocketConnection().

◆ connectionName

◆ instanceName

std::string core::socket::stream::SocketConnection::instanceName
protected

Definition at line 122 of file SocketConnection.h.

Referenced by getInstanceName(), and SocketConnection().

◆ newSocketContext

◆ socketContext


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