acl/lib_acl_cpp/samples/connect_manager/check_async.cpp

62 lines
1.3 KiB
C++
Raw Normal View History

#include "stdafx.h"
#include "check_async.h"
check_async::check_async(acl::check_client& checker)
: checker_(checker)
{
}
check_async::~check_async(void)
{
}
bool check_async::read_callback(char* data, int len)
{
// <20><>Ϊ acl <20><><EFBFBD>첽 IO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ϶<DDBF><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \0<><30>
// <20><><EFBFBD><EFBFBD>ֱ<EFBFBD>ӵ<EFBFBD><D3B5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƚ<EFBFBD><C8BD>ڴ˴<DAB4><CBB4>ǰ<EFBFBD>ȫ<EFBFBD><C8AB>
if (strncasecmp(data, "+OK", 3) == 0)
{
// <20><><EFBFBD><EFBFBD> QUIT <20><><EFBFBD><EFBFBD>
checker_.get_conn().format("QUIT\r\n");
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>״̬
checker_.set_alive(true);
// <20><><EFBFBD><EFBFBD><EFBFBD>رոü<D5B8><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
checker_.close();
// <20>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD> true <20><> false <20><><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>رռ<D8B1><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf(">>> NIO_CHECK SERVER(%s) OK: %s, len: %d <<<\r\n",
checker_.get_addr(), data, len);
return true;
}
// <20><><EFBFBD><EFBFBD> QUIT <20><><EFBFBD><EFBFBD>
checker_.get_conn().format("QUIT\r\n");
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
checker_.set_alive(false);
printf(">>> NIO_CHECK SERVER(%s) ERROR: %s, len: %d <<<\r\n",
checker_.get_addr(), data, len);
// <20><><EFBFBD><EFBFBD> false ֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>رո<D8B1><D5B8><EFBFBD><EFBFBD><EFBFBD>
return false;
}
bool check_async::timeout_callback()
{
// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
checker_.set_alive(false);
// <20><><EFBFBD><EFBFBD> false ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>رոü<D5B8><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
return false;
}
void check_async::close_callback()
{
// <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>̬ɾ<CCAC><C9BE>
delete this;
}