diff --git a/server/wsproxy/master.h b/server/wsproxy/master.h index a420210..8502cb7 100644 --- a/server/wsproxy/master.h +++ b/server/wsproxy/master.h @@ -7,7 +7,6 @@ namespace a8 class TcpClient; } -struct timer_list; class Master { public: diff --git a/server/wsproxy/precompile.h b/server/wsproxy/precompile.h index 63f6ff8..d21a05a 100644 --- a/server/wsproxy/precompile.h +++ b/server/wsproxy/precompile.h @@ -2,6 +2,7 @@ #include #include +#include #include "constant.h" #include "types.h" diff --git a/server/wsproxy/upstream.cc b/server/wsproxy/upstream.cc index 9ea53b8..3de2dab 100644 --- a/server/wsproxy/upstream.cc +++ b/server/wsproxy/upstream.cc @@ -34,15 +34,15 @@ void UpStream::Init(int instance_id, const std::string& remote_ip, int remote_po tcp_client_->on_connect = std::bind(&UpStream::on_connect, this, std::placeholders::_1); tcp_client_->on_disconnect = std::bind(&UpStream::on_disconnect, this, std::placeholders::_1); tcp_client_->on_socketread = std::bind(&UpStream::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) - { - UpStream* conn = (UpStream*)param.sender.GetUserData(); - conn->CheckAlive(); - }); - #endif + timer_wp_ = f8::Timer::Instance()->SetIntervalWpEx + (1000 * 9 + a8::RandEx(500, 150), + [this] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + CheckAlive(); + } + }, + &attacher_); } void UpStream::UnInit() diff --git a/server/wsproxy/upstream.h b/server/wsproxy/upstream.h index 0af1eb9..e0b37c3 100644 --- a/server/wsproxy/upstream.h +++ b/server/wsproxy/upstream.h @@ -17,7 +17,6 @@ struct UpStreamMsgNode UpStreamMsgNode* next_node = nullptr; }; -struct timer_list; class UpStream { public: @@ -68,7 +67,8 @@ class UpStream char *recv_buff_ = nullptr; unsigned int recv_bufflen_ = 0; std::shared_ptr tcp_client_; - timer_list* timer_ = nullptr; + f8::TimerWp timer_wp_; + f8::Attacher attacher_; UpStreamMsgNode* top_node_ = nullptr; UpStreamMsgNode* bot_node_ = nullptr;