GNet::Client Class Reference

A BufferedClient class that adds slot/signal signalling, connection/response timeouts, and input line buffering. More...

#include <gclient.h>

Inheritance diagram for GNet::Client:

GNet::HeapClient GNet::SimpleClient GNet::EventHandler GNet::Connection GNet::SocketProtocolSink GSmtp::Client GSmtp::RequestClient GSmtp::SpamClient

List of all members.

Public Member Functions

 Client (const ResolverInfo &remote_info, unsigned int connection_timeout=0U, unsigned int response_timeout=0U, const std::string &eol=std::string("\n"), const Address &local_interface=Address(0U), bool privileged=false, bool sync_dns=synchronousDnsDefault())
 Constructor.
G::Signal2< std::string, bool > & doneSignal ()
 Returns a signal that indicates that client processing is complete.
G::Signal2< std::string,
std::string > & 
eventSignal ()
 Returns a signal that indicates that something interesting has happened.
G::Signal0connectedSignal ()
 Returns a signal that incidcates that the client has successfully connected to the server.
G::Signal0secureSignal ()
 Returns a signal that incidcates that the security layer has been successfully established.

Protected Member Functions

virtual ~Client ()
 Destructor.
virtual bool onReceive (const std::string &)=0
 Called when a complete line is received from the peer.
void clearInput ()
 Clears any pending input from the server.
virtual void onDeleteImp (const std::string &, bool)
 Override from GNet::HeapClient.
virtual void onConnectImp ()
 Final override from GNet::SimpleClient.
virtual void onData (const char *, SimpleClient::size_type)
 Final override from GNet::SocketProtocolSink.
virtual void onConnecting ()
 Final override from GNet::HeapClient.
virtual void onSendImp ()
 Final override from GNet::BufferedClient.


Detailed Description

A BufferedClient class that adds slot/signal signalling, connection/response timeouts, and input line buffering.

The following pure virtual functions must be implemented by derived classes: onConnect(), onReceive(), onDelete(), and onSendComplete().

The intention is that derived classes use the virtual functions for event notification while the slot/signal event notifications are used by the containing object (in particular so that the container is informed when the client object deletes itself).

Definition at line 51 of file gclient.h.


Constructor & Destructor Documentation

GNet::Client::Client ( const ResolverInfo remote_info,
unsigned int  connection_timeout = 0U,
unsigned int  response_timeout = 0U,
const std::string &  eol = std::string("\n"),
const Address local_interface = Address(0U),
bool  privileged = false,
bool  sync_dns = synchronousDnsDefault() 
) [explicit]

Constructor.

Definition at line 25 of file gclient.cpp.

GNet::Client::~Client (  )  [protected, virtual]

Destructor.

Reimplemented in GSmtp::Client.

Definition at line 41 of file gclient.cpp.


Member Function Documentation

G::Signal2< std::string, bool > & GNet::Client::doneSignal (  ) 

Returns a signal that indicates that client processing is complete.

The first signal parameter is a failure reason, or the empty string on success. The second parameter gives some idea of whether the connection can be retried later.

Definition at line 84 of file gclient.cpp.

G::Signal2< std::string, std::string > & GNet::Client::eventSignal (  ) 

Returns a signal that indicates that something interesting has happened.

Typically used for progress logging.

The first signal parameter is one of "connecting", "connected", "sending", "failed" (on error) or "done" (for normal termination).

Definition at line 89 of file gclient.cpp.

Referenced by GSmtp::SpamClient::onDeleteImp(), GSmtp::RequestClient::onDeleteImp(), and GSmtp::RequestClient::onReceive().

G::Signal0 & GNet::Client::connectedSignal (  ) 

Returns a signal that incidcates that the client has successfully connected to the server.

Definition at line 94 of file gclient.cpp.

G::Signal0& GNet::Client::secureSignal (  ) 

Returns a signal that incidcates that the security layer has been successfully established.

virtual bool GNet::Client::onReceive ( const std::string &   )  [protected, pure virtual]

Called when a complete line is received from the peer.

The implementation should return false if no more lines should be delivered, if for example the object has deleted itself.

Implemented in GSmtp::RequestClient, GSmtp::Client, and GSmtp::SpamClient.

Referenced by onData().

void GNet::Client::clearInput (  )  [protected]

Clears any pending input from the server.

Definition at line 115 of file gclient.cpp.

References GNet::LineBuffer::discard(), and GNet::LineBuffer::more().

Referenced by GSmtp::RequestClient::request().

void GNet::Client::onDeleteImp ( const std::string &  reason,
bool  retry 
) [protected, virtual]

Override from GNet::HeapClient.

Reimplemented from GNet::HeapClient.

Reimplemented in GSmtp::RequestClient, and GSmtp::SpamClient.

Definition at line 60 of file gclient.cpp.

References G::Signal2< P1, P2 >::emit().

Referenced by GSmtp::SpamClient::onDeleteImp(), and GSmtp::RequestClient::onDeleteImp().

void GNet::Client::onConnectImp (  )  [protected, virtual]

Final override from GNet::SimpleClient.

Reimplemented from GNet::SimpleClient.

Definition at line 50 of file gclient.cpp.

References G::Signal2< P1, P2 >::emit(), G::Signal0::emit(), and GNet::SimpleClient::resolverInfo().

void GNet::Client::onData ( const char *  p,
SimpleClient::size_type  n 
) [protected, virtual]

void GNet::Client::onConnecting (  )  [protected, virtual]

Final override from GNet::HeapClient.

Reimplemented from GNet::HeapClient.

Definition at line 45 of file gclient.cpp.

References G::Signal2< P1, P2 >::emit(), and GNet::SimpleClient::resolverInfo().

void GNet::Client::onSendImp (  )  [protected, virtual]

Final override from GNet::BufferedClient.

Reimplemented from GNet::SimpleClient.

Definition at line 68 of file gclient.cpp.


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

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5