2014-11-19 00:25:21 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
class res_callback;
|
|
|
|
|
|
|
|
|
|
class req_callback : public acl::aio_callback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
req_callback(acl::aio_socket_stream* conn,
|
|
|
|
|
acl::ofstream* req_fp, acl::ofstream* res_fp);
|
|
|
|
|
~req_callback();
|
|
|
|
|
|
|
|
|
|
void start(const char* server_addr);
|
|
|
|
|
|
|
|
|
|
void disconnect();
|
|
|
|
|
void on_connected();
|
|
|
|
|
|
|
|
|
|
acl::aio_socket_stream& get_conn();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
/**
|
|
|
|
|
* ʵ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param data {char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
|
|
|
|
|
* @param len {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>رո<EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
virtual bool read_callback(char* data, int len);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ʵ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>ɹ<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>رո<EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
virtual bool write_callback()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ʵ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺرջص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
virtual void close_callback();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ʵ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>ʱ<EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>رո<EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
virtual bool timeout_callback()
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> false ֪ͨ<CDA8>첽<EFBFBD><ECB2BD><EFBFBD>ܹرո<D8B1><D5B8>첽<EFBFBD><ECB2BD>
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
acl::aio_socket_stream* conn_;
|
|
|
|
|
res_callback* res_;
|
|
|
|
|
acl::ofstream* req_fp_;
|
|
|
|
|
acl::ofstream* res_fp_;
|
|
|
|
|
};
|