A client class that interacts with a remote process with a stateless line-based request/response protocol. More...
#include <grequestclient.h>
Public Member Functions | |
RequestClient (const std::string &key, const std::string &ok, const std::string &eol, const GNet::ResolverInfo &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 ResolverInfo &remote_info, unsigned int connection_timeout=0U, unsigned int response_timeout=0U, unsigned int secure_connection_timeout=0U, const std::string &eol=std::string("\n"), const Address &local_interface=Address(0U), bool privileged=false, bool sync_dns=synchronousDnsDefault()) | |
Constructor. More... | |
G::Signal2< std::string, bool > & | doneSignal () |
Returns a signal that indicates that client processing is complete. More... | |
G::Signal2< std::string, std::string > & | eventSignal () |
Returns a signal that indicates that something interesting has happened. More... | |
G::Signal0 & | connectedSignal () |
Returns a signal that incidcates that the client has successfully connected to the server. More... | |
G::Signal0 & | secureSignal () |
Returns a signal that incidcates that the security layer has been successfully established. More... | |
Public Member Functions inherited from GNet::HeapClient | |
HeapClient (const ResolverInfo &remote_info, const Address &local_interface=Address(0U), bool privileged=false, 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". More... | |
virtual void | onException (std::exception &) |
Final override from GNet::EventHandler. More... | |
void | doDeleteForExit () |
A destructor method that may be called at program termination when the normal doDelete() mechanism has become unusable. More... | |
Public Member Functions inherited from GNet::SimpleClient | |
SimpleClient (const ResolverInfo &remote_info, const Address &local_address=Address(0U), bool privileged=false, bool sync_dns=synchronousDnsDefault(), unsigned int secure_connection_timeout=0U) | |
Constructor. More... | |
void | connect () |
Initates a connection to the remote server. More... | |
bool | connected () const |
Returns true if connected to the peer. More... | |
virtual std::pair< bool, Address > | localAddress () const |
Override from Connection. More... | |
virtual std::pair< bool, Address > | peerAddress () const |
Override from Connection. More... | |
virtual std::string | peerCertificate () const |
Returns the peer's TLS certificate. More... | |
ResolverInfo | resolverInfo () const |
Returns a ResolverInfo structure containing the result of host() and service() name lookup if available. More... | |
void | updateResolverInfo (const ResolverInfo &) |
Updates the constructor's ResolverInfo object with the given one as long as both objects have the same host and service name. More... | |
virtual void | readEvent () |
Final override from GNet::EventHandler. More... | |
virtual void | writeEvent () |
Final override from GNet::EventHandler. More... | |
bool | send (const std::string &data, std::string::size_type offset=0) |
Returns true if all sent, or false if flow control was asserted. More... | |
Public Member Functions inherited from GNet::EventHandler | |
virtual | ~EventHandler () |
Destructor. More... | |
virtual void | exceptionEvent () |
Called for an exception event. More... | |
Public Member Functions inherited from GNet::Connection | |
virtual | ~Connection () |
Destructor. More... | |
Public Member Functions inherited from GNet::SocketProtocolSink | |
virtual | ~SocketProtocolSink () |
Destructor. More... | |
Protected Member Functions | |
virtual | ~RequestClient () |
Destructor. More... | |
virtual void | onConnect () |
Final override from GNet::SimpleClient. More... | |
virtual bool | onReceive (const std::string &) |
Final override from GNet::Client. More... | |
virtual void | onSendComplete () |
Final override from GNet::BufferedClient. More... | |
virtual void | onDelete (const std::string &, bool) |
Final override from GNet::HeapClient. More... | |
virtual void | onDeleteImp (const std::string &, bool) |
Final override from GNet::Client. More... | |
virtual void | onSecure (const std::string &) |
Final override from GNet::SocketProtocolSink. More... | |
Protected Member Functions inherited from GNet::Client | |
virtual | ~Client () |
Destructor. More... | |
void | clearInput () |
Clears any pending input from the server. More... | |
virtual void | onConnectImp () |
Final override from GNet::SimpleClient. More... | |
virtual void | onData (const char *, SimpleClient::size_type) |
Final override from GNet::SocketProtocolSink. More... | |
virtual void | onConnecting () |
Final override from GNet::HeapClient. More... | |
virtual void | onSendImp () |
Final override from GNet::SimpleClient. More... | |
Protected Member Functions inherited from GNet::HeapClient | |
virtual | ~HeapClient () |
Destructor. More... | |
Protected Member Functions inherited from GNet::SimpleClient | |
virtual | ~SimpleClient () |
Destructor. More... | |
StreamSocket & | socket () |
Returns a reference to the socket. Throws if not connected. More... | |
const StreamSocket & | socket () const |
Returns a const reference to the socket. Throws if not connected. More... | |
void | sslConnect () |
Starts TLS/SSL client-side negotiation. More... | |
std::string | logId () const |
Returns a identification string for logging purposes. More... | |
Additional Inherited Members | |
Public Types inherited from GNet::SimpleClient | |
enum | ConnectStatus { Success, Failure, Retry, ImmediateSuccess } |
enum | State { Idle, Resolving, Connecting, Connected, Socksing } |
typedef std::string::size_type | size_type |
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 Protected Member Functions inherited from GNet::SimpleClient | |
static bool | canRetry (const std::string &reason) |
Parses the given failure reason and returns true if the client can reasonably retry at some later time. More... | |
A client class that interacts with a remote process with a stateless line-based request/response protocol.
Definition at line 43 of file grequestclient.h.
GSmtp::RequestClient::RequestClient | ( | const std::string & | key, |
const std::string & | ok, | ||
const std::string & | eol, | ||
const GNet::ResolverInfo & | host_and_service, | ||
unsigned int | connect_timeout, | ||
unsigned int | response_timeout | ||
) |
Constructor.
The key parameter is used in the callback signal; the (optional) ok parameter is a response string that is considered to be a success response; the eol parameter is the response end-of-line.
Definition at line 28 of file grequestclient.cpp.
References GNet::ResolverInfo::displayString(), and G_DEBUG.
|
protectedvirtual |
Destructor.
Definition at line 41 of file grequestclient.cpp.
bool GSmtp::RequestClient::busy | ( | ) | const |
Returns true after request() and before the subsequent event signal.
Definition at line 67 of file grequestclient.cpp.
|
protectedvirtual |
Final override from GNet::SimpleClient.
Implements GNet::SimpleClient.
Definition at line 45 of file grequestclient.cpp.
References G_DEBUG.
|
protectedvirtual |
Final override from GNet::HeapClient.
Implements GNet::HeapClient.
Definition at line 72 of file grequestclient.cpp.
|
protectedvirtual |
Final override from GNet::Client.
Reimplemented from GNet::Client.
Definition at line 76 of file grequestclient.cpp.
References G_WARNING.
|
protectedvirtual |
Final override from GNet::Client.
Implements GNet::Client.
Definition at line 96 of file grequestclient.cpp.
References G_DEBUG, and G::Str::printable().
|
protectedvirtual |
Final override from GNet::SocketProtocolSink.
Implements GNet::SocketProtocolSink.
Definition at line 92 of file grequestclient.cpp.
|
protectedvirtual |
Final override from GNet::BufferedClient.
Implements GNet::SimpleClient.
Definition at line 109 of file grequestclient.cpp.
void GSmtp::RequestClient::request | ( | const std::string & | payload | ) |
Issues a request.
The base class's "event" signal emitted when processing is complete with a first signal parameter of the "key" string specified in the constructor call and a second parameter giving the parsed response.
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.
References G_DEBUG.