diff --git a/server/wsproxy/master.cc b/server/wsproxy/master.cc index 6b7a0bd..cbeddb2 100644 --- a/server/wsproxy/master.cc +++ b/server/wsproxy/master.cc @@ -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; diff --git a/server/wsproxy/master.h b/server/wsproxy/master.h index 14e873a..96c3980 100644 --- a/server/wsproxy/master.h +++ b/server/wsproxy/master.h @@ -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_; };