This commit is contained in:
azw 2023-04-14 08:12:07 +00:00
parent 5796e5203e
commit 03fdcc6bb7
2 changed files with 15 additions and 14 deletions

View File

@ -31,23 +31,24 @@ void Master::Init(int instance_id, const std::string& remote_ip, int remote_port
tcp_client_->on_connect = std::bind(&Master::on_connect, this, std::placeholders::_1);
tcp_client_->on_disconnect = std::bind(&Master::on_disconnect, this, std::placeholders::_1);
tcp_client_->on_socketread = std::bind(&Master::on_socketread, this ,std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
#if 0
timer_ = a8::Timer::Instance()->AddRepeatTimer(1000 * 9 + a8::RandEx(500, 150),
a8::XParams().SetSender(this),
[] (const a8::XParams& param)
{
Master* conn = (Master*)param.sender.GetUserData();
conn->CheckAlive();
});
#endif
timer_wp_ = f8::Timer::Instance()->SetIntervalWp
(1000 * 9 + a8::RandEx(500, 150),
[] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
#if 0
Master* conn = (Master*)param.sender.GetUserData();
conn->CheckAlive();
#endif
}
});
}
void Master::UnInit()
{
#if 0
a8::Timer::Instance()->DeleteTimer(timer_);
timer_ = nullptr;
#endif
if (!timer_wp_.expired()) {
f8::Timer::Instance()->Delete(timer_wp_);
}
tcp_client_->Close();
delete tcp_client_;
tcp_client_ = nullptr;

View File

@ -43,5 +43,5 @@ class Master
char *recv_buff_ = nullptr;
unsigned int recv_bufflen_ = 0;
a8::TcpClient* tcp_client_ = nullptr;
timer_list* timer_ = nullptr;
f8::TimerWp timer_wp_;
};