|
E-MailRelay
|
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 (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... | |
Public Member Functions inherited from GNet::Client | |
| Client (const Location &remote_info, unsigned int connection_timeout=0U, unsigned int response_timeout=0U, unsigned int secure_connection_timeout=0U, LineBufferConfig=LineBufferConfig(), bool bind_local_address=false, const Address &local_address=Address::defaultAddress(), bool sync_dns=synchronousDnsDefault()) | |
| Constructor. The connection is initiated asynchronously. | |
| G::Slot::Signal1< std::string > & | doneSignal () |
| Returns a signal that indicates that client processing is complete. More... | |
| G::Slot::Signal2< std::string, std::string > & | eventSignal () |
| Returns a signal that indicates that something interesting has happened. More... | |
| G::Slot::Signal0 & | connectedSignal () |
| Returns a signal that indicates that the client has successfully connected to the server. More... | |
Public Member Functions inherited from GNet::HeapClient | |
| HeapClient (const Location &remote_info, bool bind_local_address=false, const Address &local_address=Address::defaultAddress(), bool sync_dns=synchronousDnsDefault(), unsigned int secure_connection_timeout=0U) | |
| Constructor. More... | |
| void | doDelete (const std::string &reason) |
| Calls onDelete() and then does a delayed "delete this". | |
Public Member Functions inherited from GNet::SimpleClient | |
| SimpleClient (ExceptionHandler &, const Location &remote_info, bool bind_local_address=false, const Address &local_address=Address::defaultAddress(), bool sync_dns=synchronousDnsDefault(), unsigned int secure_connection_timeout=0U) | |
| Constructor. Call connect() to start connecting. | |
| void | connect () |
| Initates a connection to the remote server. More... | |
| bool | connected () const |
| Returns true if connected to the peer. | |
| virtual std::pair< bool, Address > | localAddress () const override |
| Override from Connection. More... | |
| virtual std::pair< bool, Address > | peerAddress () const override |
| Override from Connection. More... | |
| virtual std::string | connectionState () const override |
| Returns the connection state display string. More... | |
| virtual std::string | peerCertificate () const override |
| Returns the peer's TLS certificate. More... | |
| Location | remoteLocation () const |
| Returns a Location structure containing the result of host() and service() name lookup if available. More... | |
| void | updateLocation (const Location &) |
| Updates the constructor's Location object with the given one as long as both objects have the same host and service name. More... | |
| virtual void | readEvent () override |
| Override from GNet::EventHandler. | |
| virtual void | writeEvent () override |
| Override from GNet::EventHandler. | |
| virtual void | otherEvent (EventHandler::Reason) override |
| Override from GNet::EventHandler. | |
| bool | send (const std::string &data, std::string::size_type offset=0) |
| Sends data to the peer. More... | |
Public Member Functions inherited from GNet::EventHandler | |
| virtual | ~EventHandler () |
| Destructor. | |
Public Member Functions inherited from GNet::Connection | |
| virtual | ~Connection () |
| Destructor. | |
Protected Member Functions | |
| virtual | ~RequestClient () |
| Destructor. | |
| virtual void | onConnect () override |
| Override from GNet::SimpleClient. | |
| virtual bool | onReceive (const char *, size_t, size_t) override |
| Override from GNet::Client. | |
| virtual void | onSendComplete () override |
| Override from GNet::BufferedClient. | |
| virtual void | onDelete (const std::string &) override |
| Override from GNet::HeapClient. | |
| virtual void | onDeleteImp (const std::string &) override |
| Override from GNet::Client. | |
| virtual void | onSecure (const std::string &) override |
| Override from GNet::SocketProtocolSink. | |
Protected Member Functions inherited from GNet::Client | |
| virtual | ~Client () |
| Destructor. | |
| void | clearInput () |
| Clears the line buffer. More... | |
| std::string | lineBufferEndOfLine () const |
| Returns the line buffer end-of-line string. More... | |
| virtual void | onConnectImp () override |
| Override from GNet::SimpleClient. | |
| virtual void | onData (const char *, SimpleClient::size_type) override |
| Override from GNet::SocketProtocolSink. | |
| virtual void | onConnecting () override |
| Override from GNet::HeapClient. | |
| virtual void | onSendImp () override |
| Override from GNet::SimpleClient. | |
Protected Member Functions inherited from GNet::HeapClient | |
| virtual | ~HeapClient () |
| Destructor. | |
| void | finish () |
| Indicates that the last data has been sent and the client is expecting a peer disconnect. More... | |
| virtual void | onException (std::exception &) g__final override |
| Override from GNet::ExceptionHandler. More... | |
Protected Member Functions inherited from GNet::ExceptionHandler | |
| virtual | ~ExceptionHandler () |
| Destructor. | |
Protected Member Functions inherited from GNet::SimpleClient | |
| virtual | ~SimpleClient () |
| Destructor. | |
| StreamSocket & | socket () |
| Returns a reference to the socket. Throws if not connected. | |
| const StreamSocket & | socket () const |
| Returns a const reference to the socket. Throws if not connected. | |
| void | secureConnect () |
| Starts TLS/SSL client-side negotiation. More... | |
| std::string | logId () const |
| Returns a identification string for logging purposes. More... | |
| SimpleClient (ExceptionHandler &, const Location &remote_info, bool bind_local_address=false, const Address &local_address=Address::defaultAddress(), bool sync_dns=synchronousDnsDefault(), unsigned int secure_connection_timeout=0U) | |
| Constructor. Call connect() to start connecting. | |
| void | connect () |
| Initates a connection to the remote server. More... | |
| bool | connected () const |
| Returns true if connected to the peer. | |
| virtual std::pair< bool, Address > | localAddress () const override |
| Override from Connection. More... | |
| virtual std::pair< bool, Address > | peerAddress () const override |
| Override from Connection. More... | |
| virtual std::string | connectionState () const override |
| Returns the connection state display string. More... | |
| virtual std::string | peerCertificate () const override |
| Returns the peer's TLS certificate. More... | |
| Location | remoteLocation () const |
| Returns a Location structure containing the result of host() and service() name lookup if available. More... | |
| void | updateLocation (const Location &) |
| Updates the constructor's Location object with the given one as long as both objects have the same host and service name. More... | |
| virtual void | readEvent () override |
| Override from GNet::EventHandler. | |
| virtual void | writeEvent () override |
| Override from GNet::EventHandler. | |
| virtual void | otherEvent (EventHandler::Reason) override |
| Override from GNet::EventHandler. | |
| bool | send (const std::string &data, std::string::size_type offset=0) |
| Sends data to the peer. More... | |
Protected Member Functions inherited from GNet::EventHandler | |
| virtual | ~EventHandler () |
| Destructor. | |
Protected Member Functions inherited from GNet::Connection | |
| virtual | ~Connection () |
| Destructor. | |
Additional Inherited Members | |
Public Types inherited from GNet::SimpleClient | |
| enum | ConnectStatus { Success, Failure, ImmediateSuccess } |
| enum | State { Idle, Resolving, Connecting, Connected, Socksing, Testing } |
| typedef std::string::size_type | size_type |
Public Types inherited from GNet::EventHandler | |
| enum | Reason { reason_closed, reason_down, reason_reset, reason_abort, reason_other } |
Static Public Member Functions inherited from GNet::SimpleClient | |
| static bool | synchronousDnsDefault () |
| Returns true if DNS queries should normally be synchronous on this platform. More... | |
Static Public Member Functions inherited from GNet::EventHandler | |
| static std::string | str (Reason) |
| Returns a printable description of the other-event reason. More... | |
Protected Types inherited from GNet::SimpleClient | |
| enum | ConnectStatus { Success, Failure, ImmediateSuccess } |
| enum | State { Idle, Resolving, Connecting, Connected, Socksing, Testing } |
| typedef std::string::size_type | size_type |
Protected Types inherited from GNet::EventHandler | |
| enum | Reason { reason_closed, reason_down, reason_reset, reason_abort, reason_other } |
Static Protected Member Functions inherited from GNet::SimpleClient | |
| static bool | connectError (const std::string &reason) |
| Returns true if the reason string implies the SimpleClient::connect() failed. More... | |
| static bool | synchronousDnsDefault () |
| Returns true if DNS queries should normally be synchronous on this platform. More... | |
Static Protected Member Functions inherited from GNet::EventHandler | |
| static std::string | str (Reason) |
| Returns a printable description of the other-event reason. More... | |
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.
Definition at line 44 of file grequestclient.h.
| GSmtp::RequestClient::RequestClient | ( | 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 27 of file grequestclient.cpp.
| bool GSmtp::RequestClient::busy | ( | ) | const |
Returns true after request() and before the subsequent event signal.
Definition at line 74 of file grequestclient.cpp.
| 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 55 of file grequestclient.cpp.
1.8.9.1