修复imserver report问题

This commit is contained in:
aozhiwei 2020-12-28 10:47:04 +08:00
parent eae673b80a
commit 25f158b852
3 changed files with 16 additions and 7 deletions

View File

@ -36,7 +36,7 @@ void MSConn::Init(int instance_id, const std::string& remote_ip, int remote_port
tcp_client_->on_connect = std::bind(&MSConn::on_connect, this, std::placeholders::_1);
tcp_client_->on_disconnect = std::bind(&MSConn::on_disconnect, this, std::placeholders::_1);
tcp_client_->on_socketread = std::bind(&MSConn::on_socketread, this ,std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
timer_ = a8::Timer::Instance()->AddRepeatTimer
a8::Timer::Instance()->AddRepeatTimerAndAttach
(1000 * 9 + a8::RandEx(500, 150),
a8::XParams().SetSender(this),
[] (const a8::XParams& param)
@ -44,14 +44,22 @@ void MSConn::Init(int instance_id, const std::string& remote_ip, int remote_port
MSConn* conn = (MSConn*)param.sender.GetUserData();
conn->CheckAlive();
conn->SyncIMServerList();
},
&timer_attacher_.timer_list_);
a8::Timer::Instance()->AddRepeatTimerAndAttach
(800 + a8::RandEx(100, 300),
a8::XParams().SetSender(this),
[] (const a8::XParams& param)
{
MSConn* conn = (MSConn*)param.sender.GetUserData();
conn->ReportServerInfo();
});
},
&timer_attacher_.timer_list_);
}
void MSConn::UnInit()
{
a8::Timer::Instance()->DeleteTimer(timer_);
timer_ = nullptr;
timer_attacher_.ClearTimerList();
tcp_client_->Close();
a8::IoLoop::Instance()->DestoryAsyncTcpClient(tcp_client_);
tcp_client_ = nullptr;

View File

@ -1,5 +1,7 @@
#pragma once
#include <a8/timer_attacher.h>
#include "framework/cpp/protoutils.h"
#include "framework/cpp/netmsghandler.h"
@ -63,5 +65,6 @@ class MSConn
char *recv_buff_ = nullptr;
unsigned int recv_bufflen_ = 0;
a8::AsyncTcpClient* tcp_client_ = nullptr;
timer_list* timer_ = nullptr;
a8::TimerAttacher timer_attacher_;
};

View File

@ -17,9 +17,7 @@ void SvrMgr::Init()
a8::XParams(),
[] (const a8::XParams& param)
{
#ifndef DEBUG
SvrMgr::Instance()->ClearTimeOutNode();
#endif
});
}