E-MailRelay
Public Member Functions | List of all members
GSmtp::RequestClient Class Reference

A network client class that interacts with a remote server using a stateless line-based request/response protocol. More...

#include <grequestclient.h>

+ Inheritance diagram for GSmtp::RequestClient:

Public Member Functions

 RequestClient (GNet::ExceptionSink, const std::string &key, const std::string &ok, const GNet::Location &host_and_service, unsigned int connect_timeout, unsigned int response_timeout)
 Constructor. More...
 
void request (const std::string &)
 Issues a request. More...
 
bool busy () const
 Returns true after request() and before the subsequent event signal. More...
 
 RequestClient (const RequestClient &)=delete
 
 RequestClient (RequestClient &&)=delete
 
void operator= (const RequestClient &)=delete
 
void operator= (RequestClient &&)=delete
 
- Public Member Functions inherited from GNet::Client
 Client (ExceptionSink, const Location &remote_location, const Config &)
 Constructor. More...
 
void connect ()
 Initiates a connection to the remote server. More...
 
bool connected () const
 Returns true if connected to the peer. More...
 
bool hasConnected () const
 Returns true if ever connected(). More...
 
void disconnect ()
 Aborts the connection and destroys the object's internal state, resulting in a zombie object. More...
 
std::pair< bool, AddresslocalAddress () const override
 Override from Connection. More...
 
std::pair< bool, AddresspeerAddress () const override
 Override from Connection. 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...
 
Location remoteLocation () const
 Returns a Location structure, including the result of name lookup if available. More...
 
bool send (const std::string &data, std::size_t offset=0)
 Sends data to the peer and starts the response timer (if configured). More...
 
bool send (const std::vector< G::string_view > &data, std::size_t offset=0)
 Overload for scatter/gather segments. More...
 
G::Slot::Signal< const std::string &, const std::string &, const std::string & > & eventSignal () noexcept
 Returns a signal that indicates that something interesting has happened. More...
 
void doOnDelete (const std::string &reason, bool done)
 Called by ClientPtr (or equivalent) to call onDelete(), just before this client object is deleted. More...
 
bool finished () const
 Returns true if finish()ed or disconnect()ed. More...
 
LineBufferState lineBuffer () const
 Returns information about the state of the internal line-buffer. More...
 
 ~Client () override
 Destructor. More...
 
 Client (const Client &)=delete
 
 Client (Client &&)=delete
 
void operator= (const Client &)=delete
 
void operator= (Client &&)=delete
 
- Public Member Functions inherited from GNet::Connection
virtual ~Connection ()=default
 Destructor.
 
virtual std::pair< bool, AddresslocalAddress () const =0
 Returns the connection's local address. More...
 
virtual std::pair< bool, AddresspeerAddress () 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...
 
- Public Member Functions inherited from GNet::ExceptionSource
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
 

Additional Inherited Members

- Protected Member Functions inherited from GNet::Client
StreamSocketsocket ()
 Returns a reference to the socket. Throws if not connected. More...
 
const StreamSocketsocket () const
 Returns a const reference to the socket. Throws if not connected. More...
 
void finish (bool with_socket_shutdown)
 Indicates that the last data has been sent and the client is expecting a peer disconnect. More...
 
void clearInput ()
 Clears the input LineBuffer and cancels the response timer if running. More...
 
virtual bool onReceive (const char *data, std::size_t size, std::size_t eolsize, std::size_t linesize, char c0)=0
 Called with received data. More...
 
virtual void onConnect ()=0
 Called once connected.
 
virtual void onSendComplete ()=0
 Called when all residual data from send() has been sent.
 
virtual void onDelete (const std::string &reason)=0
 Called just before ClientPtr destroys the Client as the result of handling an exception. More...
 
void secureConnect ()
 Starts TLS/SSL client-side negotiation. More...
 

Detailed Description

A network client class that interacts with a remote server using a stateless line-based request/response protocol.

Line buffering uses newline as end-of-line, and trailing carriage-returns are trimmed from the input.

The received network responses are delivered via the GNet::Client class's event signal.

Definition at line 46 of file grequestclient.h.

Constructor & Destructor Documentation

◆ RequestClient()

GSmtp::RequestClient::RequestClient ( GNet::ExceptionSink  es,
const std::string &  key,
const std::string &  ok,
const GNet::Location host_and_service,
unsigned int  connect_timeout,
unsigned int  response_timeout 
)

Constructor.

The 'key' parameter is used in the callback signal. The 'ok' parameter is a response string that is converted to the empty string.

Definition at line 25 of file grequestclient.cpp.

Member Function Documentation

◆ busy()

bool GSmtp::RequestClient::busy ( ) const

Returns true after request() and before the subsequent event signal.

Definition at line 73 of file grequestclient.cpp.

◆ request()

void GSmtp::RequestClient::request ( const std::string &  request_payload)

Issues a request.

A newline is added to the request string, so append a carriage-return if required.

If not currently connected then the request is queued up until the connection is made.

The base class's "event" signal will be emitted when processing is complete. In this case the first signal parameter will be the "key" string specified in the constructor call and the second will be the parsed response.

See also GNet::Client::eventSignal().

Every request will get a single response as long as this method is not called re-entrantly from within the previous request's response signal.

Definition at line 52 of file grequestclient.cpp.


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