2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2015-04-04 15:25:29 +08:00
|
|
|
|
#include <map>
|
|
|
|
|
#include <vector>
|
2015-06-29 17:33:11 +08:00
|
|
|
|
#if !defined(_WIN32) && !defined(_WIN64)
|
2015-05-21 21:49:35 +08:00
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#endif
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stream/aio_socket_stream.hpp"
|
|
|
|
|
#include "../stdlib/string.hpp"
|
2015-04-04 15:25:29 +08:00
|
|
|
|
|
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class check_timer;
|
|
|
|
|
class aio_socket_stream;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD>ӻص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-04 15:25:29 +08:00
|
|
|
|
*/
|
|
|
|
|
class ACL_CPP_API check_client : public aio_open_callback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
check_client(check_timer& timer, const char* addr,
|
|
|
|
|
aio_socket_stream& conn, struct timeval& begin);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IO <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-04 15:25:29 +08:00
|
|
|
|
* @return {aio_socket_stream&}
|
|
|
|
|
*/
|
|
|
|
|
aio_socket_stream& get_conn() const
|
|
|
|
|
{
|
|
|
|
|
return conn_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>ַ
|
2015-04-04 15:25:29 +08:00
|
|
|
|
* @return {const char*}
|
|
|
|
|
*/
|
|
|
|
|
const char* get_addr() const
|
|
|
|
|
{
|
|
|
|
|
return addr_.c_str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>Ǵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-04 15:25:29 +08:00
|
|
|
|
* @param yesno {bool}
|
|
|
|
|
*/
|
|
|
|
|
void set_alive(bool yesno);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>رշ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IO <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-04 15:25:29 +08:00
|
|
|
|
*/
|
|
|
|
|
void close();
|
|
|
|
|
|
|
|
|
|
public:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD>µĺ<C2B5><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>ʹ<EFBFBD><CAB9>
|
2015-04-04 15:25:29 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>
|
2015-04-04 15:25:29 +08:00
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
|
|
|
|
bool blocked() const
|
|
|
|
|
{
|
|
|
|
|
return blocked_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <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><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><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD>ֹͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD> close <EFBFBD><EFBFBD><EFBFBD>رյ<EFBFBD>
|
|
|
|
|
* @param on {bool} <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><EFBFBD><EFBFBD><EFBFBD>״̬
|
2015-04-04 15:25:29 +08:00
|
|
|
|
*/
|
|
|
|
|
void set_blocked(bool on);
|
|
|
|
|
|
|
|
|
|
private:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><E9BAAF>
|
2015-04-04 15:25:29 +08:00
|
|
|
|
bool open_callback();
|
|
|
|
|
void close_callback();
|
|
|
|
|
bool timeout_callback();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
~check_client() {}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool blocked_;
|
|
|
|
|
bool aliving_;
|
2018-06-05 14:42:35 +08:00
|
|
|
|
bool timedout_;
|
2015-04-04 15:25:29 +08:00
|
|
|
|
struct timeval begin_;
|
|
|
|
|
check_timer& timer_;
|
|
|
|
|
aio_socket_stream& conn_;
|
|
|
|
|
string addr_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|