本文整理汇总了C++中TCPClient::StopReconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ TCPClient::StopReconnect方法的具体用法?C++ TCPClient::StopReconnect怎么用?C++ TCPClient::StopReconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPClient
的用法示例。
在下文中一共展示了TCPClient::StopReconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AfterConnect
void TCPClient::AfterConnect(uv_connect_t* handle, int status)
{
TcpClientCtx* theclass = (TcpClientCtx*)handle->handle->data;
TCPClient* parent = (TCPClient*)theclass->parent_server;
if (status) {
parent->connectstatus_ = CONNECT_ERROR;
parent->errmsg_ = GetUVError(status);
LOG(ERROR)<<"client(" << parent << ") connect error:" << parent->errmsg_;
fprintf(stdout, "connect error:%s\n", parent->errmsg_.c_str());
if (parent->isreconnecting_) {//reconnect failure, restart timer to trigger reconnect.
uv_timer_stop(&parent->reconnect_timer_);
parent->repeat_time_ *= 2;
uv_timer_start(&parent->reconnect_timer_, TCPClient::ReconnectTimer, parent->repeat_time_, parent->repeat_time_);
}
return;
}
int iret = uv_read_start(handle->handle, AllocBufferForRecv, AfterRecv);
if (iret) {
parent->errmsg_ = GetUVError(status);
LOG(ERROR)<<"client(" << parent << ") uv_read_start error:" << parent->errmsg_;
fprintf(stdout, "uv_read_start error:%s\n", parent->errmsg_.c_str());
parent->connectstatus_ = CONNECT_ERROR;
} else {
parent->connectstatus_ = CONNECT_FINISH;
LOG(INFO) << "client(" << parent << ")run";
}
if (parent->isreconnecting_) {
fprintf(stdout, "reconnect succeed\n");
parent->StopReconnect();//reconnect succeed.
if (parent->reconnectcb_) {
parent->reconnectcb_(NET_EVENT_TYPE_RECONNECT, parent->reconnect_userdata_);
}
}
}