E-MailRelay
|
An abstract base class for the GNet::Server's connection to a remote client. More...
#include <gserverpeer.h>
Public Member Functions | |
ServerPeer (ExceptionSink, const ServerPeerInfo &, const LineBufferConfig &) | |
Constructor. More... | |
~ServerPeer () override | |
Destructor. More... | |
bool | send (const std::string &data, std::size_t offset=0U) |
Sends data down the socket to the peer. More... | |
bool | send (const std::vector< G::string_view > &data) |
Overload to send data using scatter-gather segments. More... | |
std::pair< bool, Address > | localAddress () const override |
Returns the local address. More... | |
std::pair< bool, Address > | peerAddress () const override |
Returns the peer address. More... | |
std::string | connectionState () const override |
Returns the connection state display string. More... | |
std::string | peerCertificate () const override |
Returns the peer's TLS certificate. More... | |
void | doOnDelete (const std::string &reason, bool done) |
Used by the Server class to call onDelete(). More... | |
LineBufferState | lineBuffer () const |
Returns information about the state of the internal line-buffer. More... | |
ServerPeer (const ServerPeer &)=delete | |
ServerPeer (ServerPeer &&)=delete | |
void | operator= (const ServerPeer &)=delete |
void | operator= (ServerPeer &&)=delete |
![]() | |
virtual | ~Connection ()=default |
Destructor. | |
virtual std::pair< bool, Address > | localAddress () const =0 |
Returns the connection's local address. More... | |
virtual std::pair< bool, Address > | peerAddress () const =0 |
Returns the connection's peer address. More... | |
virtual std::string | connectionState () const =0 |
Returns the connection state as a display string. More... | |
virtual std::string | peerCertificate () const =0 |
Returns the peer's TLS certificate. More... | |
![]() | |
virtual std::string | exceptionSourceId () const |
Returns an identifying string for logging purposes, or the empty string. More... | |
virtual | ~ExceptionSource () |
Destructor. More... | |
ExceptionSource (const ExceptionSource &)=delete | |
ExceptionSource (ExceptionSource &&)=delete | |
void | operator= (const ExceptionSource &)=delete |
void | operator= (ExceptionSource &&)=delete |
Protected Member Functions | |
virtual void | onSendComplete ()=0 |
Called after flow-control has been released and all residual data sent. | |
virtual bool | onReceive (const char *data, std::size_t size, std::size_t eolsize, std::size_t linesize, char c0)=0 |
Called on receipt of data. See GNet::LineBuffer. | |
virtual void | onDelete (const std::string &reason)=0 |
Called just before the Server deletes this ServerPeer as the result of an exception (but not as a result of Server destruction). More... | |
void | secureAccept () |
Waits for the peer to start a secure session. More... | |
StreamSocket & | socket () |
Returns a reference to the client-server connection socket. More... | |
void | expect (std::size_t) |
Modifies the line buffer state so that it delivers a chunk of non-line-delimited data. More... | |
void | onData (const char *, std::size_t) override |
Override from GNet::SocketProtocolSink. More... | |
An abstract base class for the GNet::Server's connection to a remote client.
Instances are created on the heap by the Server::newPeer() override. Exceptions are delivered to the owning Server and result in a call to the relevant ServerPeer's onDelete() method followed by its deletion.
Definition at line 67 of file gserverpeer.h.
GNet::ServerPeer::ServerPeer | ( | ExceptionSink | es, |
const ServerPeerInfo & | peer_info, | ||
const LineBufferConfig & | line_buffer_config | ||
) |
Constructor.
This constructor is only used from within the override of GNet::Server::newPeer(). The ExceptionSink refers to the owning Server.
Definition at line 28 of file gserverpeer.cpp.
|
override |
Destructor.
Definition at line 50 of file gserverpeer.cpp.
|
overridevirtual |
Returns the connection state display string.
Override from GNet::Connection.
Implements GNet::Connection.
Definition at line 93 of file gserverpeer.cpp.
void GNet::ServerPeer::doOnDelete | ( | const std::string & | reason, |
bool | done | ||
) |
Used by the Server class to call onDelete().
Definition at line 119 of file gserverpeer.cpp.
|
protected |
Modifies the line buffer state so that it delivers a chunk of non-line-delimited data.
Definition at line 61 of file gserverpeer.cpp.
GNet::LineBufferState GNet::ServerPeer::lineBuffer | ( | ) | const |
Returns information about the state of the internal line-buffer.
Definition at line 147 of file gserverpeer.cpp.
|
overridevirtual |
Returns the local address.
Pair.first is false on error. Override from GNet::Connection.
Implements GNet::Connection.
Definition at line 82 of file gserverpeer.cpp.
|
overrideprotectedvirtual |
Override from GNet::SocketProtocolSink.
Protected to allow derived classes to ignore incoming data for DoS prevention.
Implements GNet::SocketProtocolSink.
Definition at line 132 of file gserverpeer.cpp.
|
protectedpure virtual |
Called just before the Server deletes this ServerPeer as the result of an exception (but not as a result of Server destruction).
The reason is the empty string if caused by a GNet::Done exception. Consider making the implementation non-throwing, in the spirit of a destructor, since the ServerPeer object is about to be deleted.
|
overridevirtual |
Returns the peer address.
Override from GNet::Connection.
Implements GNet::Connection.
Definition at line 88 of file gserverpeer.cpp.
|
overridevirtual |
Returns the peer's TLS certificate.
Override from GNet::Connection.
Implements GNet::Connection.
Definition at line 98 of file gserverpeer.cpp.
|
protected |
Waits for the peer to start a secure session.
Uses a profile called "server"; see GSsl::Library::addProfile(). The callback GNet::SocketProtocolSink::onSecure() is triggered when the secure session is established.
Definition at line 56 of file gserverpeer.cpp.
bool GNet::ServerPeer::send | ( | const std::string & | data, |
std::size_t | offset = 0U |
||
) |
Sends data down the socket to the peer.
Returns true if completely sent; returns false if flow control asserted (see onSendComplete()). If flow control is asserted then there should be no new calls to send() until onSendComplete() is triggered. Throws on error.
bool GNet::ServerPeer::send | ( | const std::vector< G::string_view > & | data | ) |
Overload to send data using scatter-gather segments.
If false is returned then segment data pointers must stay valid until onSendComplete() is triggered.
Definition at line 108 of file gserverpeer.cpp.
|
protected |
Returns a reference to the client-server connection socket.
Definition at line 66 of file gserverpeer.cpp.