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_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_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); tcp_client_->on_socketread = std::bind(&Master::on_socketread, this ,std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
#if 0 timer_wp_ = f8::Timer::Instance()->SetIntervalWp
timer_ = a8::Timer::Instance()->AddRepeatTimer(1000 * 9 + a8::RandEx(500, 150), (1000 * 9 + a8::RandEx(500, 150),
a8::XParams().SetSender(this), [] (int event, const a8::Args* args)
[] (const a8::XParams& param) {
{ if (a8::TIMER_EXEC_EVENT == event) {
Master* conn = (Master*)param.sender.GetUserData(); #if 0
conn->CheckAlive(); Master* conn = (Master*)param.sender.GetUserData();
}); conn->CheckAlive();
#endif #endif
}
});
} }
void Master::UnInit() void Master::UnInit()
{ {
#if 0 if (!timer_wp_.expired()) {
a8::Timer::Instance()->DeleteTimer(timer_); f8::Timer::Instance()->Delete(timer_wp_);
timer_ = nullptr; }
#endif
tcp_client_->Close(); tcp_client_->Close();
delete tcp_client_; delete tcp_client_;
tcp_client_ = nullptr; tcp_client_ = nullptr;

View File

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