acl/lib_acl_cpp/samples/master_aio_proxy/req_callback.h

58 lines
1.4 KiB
C
Raw Normal View History

#pragma once
2014-11-19 00:25:21 +08:00
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:
/**
*
* @param data {char*}
* @param len {int}
* @return {bool} true
2014-11-19 00:25:21 +08:00
*/
virtual bool read_callback(char* data, int len);
/**
*
* @return {bool} true
2014-11-19 00:25:21 +08:00
*/
virtual bool write_callback()
{
return true;
}
/**
*
2014-11-19 00:25:21 +08:00
*/
virtual void close_callback();
/**
*
* @return {bool} true
2014-11-19 00:25:21 +08:00
*/
virtual bool timeout_callback()
{
// 返回 false 通知异步框架关闭该异步流
2014-11-19 00:25:21 +08:00
return false;
}
private:
acl::aio_socket_stream* conn_;
res_callback* res_;
acl::ofstream* req_fp_;
acl::ofstream* res_fp_;
};