This commit is contained in:
azw 2023-04-14 09:08:57 +00:00
parent a61719966e
commit ba2151d25c
4 changed files with 12 additions and 12 deletions

View File

@ -7,7 +7,6 @@ namespace a8
class TcpClient;
}
struct timer_list;
class Master
{
public:

View File

@ -2,6 +2,7 @@
#include <a8/a8.h>
#include <f8/f8.h>
#include <f8/timer.h>
#include "constant.h"
#include "types.h"

View File

@ -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()

View File

@ -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<a8::TcpClient> tcp_client_;
timer_list* timer_ = nullptr;
f8::TimerWp timer_wp_;
f8::Attacher attacher_;
UpStreamMsgNode* top_node_ = nullptr;
UpStreamMsgNode* bot_node_ = nullptr;