26 unsigned int response_timeout ,
unsigned int secure_connection_timeout ,
27 const std::string & eol ,
const Address & local_interface ,
28 bool privileged ,
bool sync_dns ) :
29 HeapClient(remote_info,local_interface,privileged,sync_dns,secure_connection_timeout) ,
31 m_connected_signal(true) ,
32 m_connection_timeout(connection_timeout) ,
33 m_response_timeout(response_timeout) ,
34 m_connection_timer(*this,&
Client::onConnectionTimeout,*this) ,
35 m_response_timer(*this,&
Client::onResponseTimeout,*this) ,
38 if( connection_timeout != 0U )
39 m_connection_timer.startTimer( connection_timeout ) ;
48 m_event_signal.emit(
"connecting" , resolverInfo().displayString() ) ;
53 if( m_connection_timeout != 0U )
54 m_connection_timer.cancelTimer() ;
56 m_connected_signal.emit() ;
58 m_event_signal.emit(
"connected" , resolverInfo().address().displayString() +
" " + resolverInfo().name() ) ;
63 m_connection_timer.cancelTimer() ;
64 m_response_timer.cancelTimer() ;
65 m_event_signal.emit( reason.empty() ?
"done" :
"failed" , reason ) ;
66 m_done_signal.emit( reason , retry ) ;
71 if( m_response_timeout != 0U )
72 m_response_timer.startTimer( m_response_timeout ) ;
75 void GNet::Client::onConnectionTimeout()
77 doDelete(
"connection timeout" ) ;
80 void GNet::Client::onResponseTimeout()
82 doDelete(
"response timeout" ) ;
87 return m_done_signal ;
92 return m_event_signal ;
97 return m_connected_signal ;
102 return m_secure_signal ;
107 m_line_buffer.add(p,n) ;
110 while( m_line_buffer.more() )
112 if( first && m_response_timeout != 0U )
113 m_response_timer.cancelTimer() ;
116 bool ok = onReceive( m_line_buffer.line() ) ;
124 while( m_line_buffer.more() )
125 m_line_buffer.discard() ;
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.
std::string::size_type size_type
virtual void onSendImp()
Final override from GNet::SimpleClient.
G::Signal0 & connectedSignal()
Returns a signal that incidcates that the client has successfully connected to the server...
The Address class encapsulates an IP transport address.
G::Signal2< std::string, bool > & doneSignal()
Returns a signal that indicates that client processing is complete.
A class that holds a host/service name pair and optionally the results of a name-to-address lookup...
virtual void onDeleteImp(const std::string &, bool)
Override from GNet::HeapClient.
G::Signal2< std::string, std::string > & eventSignal()
Returns a signal that indicates that something interesting has happened.
virtual ~Client()
Destructor.
virtual void onData(const char *, SimpleClient::size_type)
Final override from GNet::SocketProtocolSink.
void clearInput()
Clears any pending input from the server.
A SimpleClient class for client objects that manage their own lifetime on the heap.
Part of the slot/signal system.
G::Signal0 & secureSignal()
Returns a signal that incidcates that the security layer has been successfully established.
virtual void onConnectImp()
Final override from GNet::SimpleClient.
A HeapClient class that adds slot/signal signalling, connection/response timeouts, and input line buffering.
virtual void onConnecting()
Final override from GNet::HeapClient.