This commit is contained in:
aozhiwei 2020-05-02 23:59:09 +08:00
parent 746c982fab
commit 0c214177a4
5 changed files with 0 additions and 72 deletions

View File

@ -65,7 +65,6 @@ static void SavePerfLog()
App::Instance()->perf.max_login_time,
App::Instance()->perf.max_join_time,
});
#if ASYNC_TCPCLIENT && GAME_ID == 2002
a8::UdpLog::Instance()->Info(" run_times:%d timer_times:%d event_times:%d free_times:%d "
" shutdown_times:%d connect_times:%d close_times:%d "
" send_times:%d recv_times:%d error_times:%d immsg_times:%d",
@ -82,7 +81,6 @@ static void SavePerfLog()
(long long)a8::IoLoop::Instance()->error_times,
(long long)a8::IoLoop::Instance()->immsg_times
});
#endif
if (App::Instance()->HasFlag(2)) {
a8::XPrintf("mainloop_time:%d netmsg_time:%d send_node_num:%d sent_bytes_num:%d\n",
{

View File

@ -23,11 +23,7 @@ void MasterSvr::Init(int instance_id, const std::string& remote_ip, int remote_p
recv_bufflen_ = 0;
last_pong_tick = a8::XGetTickCount();
recv_buff_ = (char*) malloc(PACK_MAX * 2);
#if ASYNC_TCPCLIENT
tcp_client_ = a8::IoLoop::Instance()->CreateAsyncTcpClient();
#else
tcp_client_ = new a8::TcpClient();
#endif
tcp_client_->remote_address = remote_ip;
tcp_client_->remote_port = remote_port;
tcp_client_->on_error = std::bind(&MasterSvr::on_error, this, std::placeholders::_1, std::placeholders::_2);
@ -48,11 +44,7 @@ void MasterSvr::UnInit()
a8::Timer::Instance()->DeleteTimer(timer_);
timer_ = nullptr;
tcp_client_->Close();
#if ASYNC_TCPCLIENT
a8::IoLoop::Instance()->DestoryAsyncTcpClient(tcp_client_);
#else
delete tcp_client_;
#endif
tcp_client_ = nullptr;
recv_bufflen_ = 0;
free(recv_buff_);
@ -74,11 +66,7 @@ bool MasterSvr::Connected()
return tcp_client_->Connected();
}
#if ASYNC_TCPCLIENT
void MasterSvr::on_error(a8::AsyncTcpClient* sender, int errorId)
#else
void MasterSvr::on_error(a8::TcpClient* sender, int errorId)
#endif
{
a8::UdpLog::Instance()->Error("MasterSvr errorid=%d remote_ip:%s remote_port:%d",
{
@ -88,21 +76,13 @@ void MasterSvr::on_error(a8::TcpClient* sender, int errorId)
});
}
#if ASYNC_TCPCLIENT
void MasterSvr::on_connect(a8::AsyncTcpClient* sender)
#else
void MasterSvr::on_connect(a8::TcpClient* sender)
#endif
{
recv_bufflen_ = 0;
a8::UdpLog::Instance()->Info("masterserver connected", {});
}
#if ASYNC_TCPCLIENT
void MasterSvr::on_disconnect(a8::AsyncTcpClient* sender)
#else
void MasterSvr::on_disconnect(a8::TcpClient* sender)
#endif
{
recv_bufflen_ = 0;
a8::UdpLog::Instance()->Info("masterserver %d disconnected after 10s later reconnect", {instance_id});
@ -112,11 +92,7 @@ void MasterSvr::on_disconnect(a8::TcpClient* sender)
);
}
#if ASYNC_TCPCLIENT
void MasterSvr::on_socketread(a8::AsyncTcpClient* sender, char* buf, unsigned int len)
#else
void MasterSvr::on_socketread(a8::TcpClient* sender, char* buf, unsigned int len)
#endif
{
#if 0
++App::Instance()->perf.read_count;

View File

@ -33,27 +33,16 @@ class MasterSvr
}
private:
#if ASYNC_TCPCLIENT
void on_error(a8::AsyncTcpClient* sender, int errorId);
void on_connect(a8::AsyncTcpClient* sender);
void on_disconnect(a8::AsyncTcpClient* sender);
void on_socketread(a8::AsyncTcpClient* sender, char* buf, unsigned int len);
#else
void on_error(a8::TcpClient* sender, int errorId);
void on_connect(a8::TcpClient* sender);
void on_disconnect(a8::TcpClient* sender);
void on_socketread(a8::TcpClient* sender, char* buf, unsigned int len);
#endif
void CheckAlive();
private:
char *recv_buff_ = nullptr;
unsigned int recv_bufflen_ = 0;
#if ASYNC_TCPCLIENT
a8::AsyncTcpClient* tcp_client_ = nullptr;
#else
a8::TcpClient* tcp_client_ = nullptr;
#endif
timer_list* timer_ = nullptr;
};

View File

@ -26,11 +26,7 @@ void TargetConn::Init(int instance_id, const std::string& remote_ip, int remote_
recv_bufflen_ = 0;
last_pong_tick = a8::XGetTickCount();
recv_buff_ = (char*) malloc(PACK_MAX * 2);
#if ASYNC_TCPCLIENT && GAME_ID == 2002
tcp_client_ = a8::IoLoop::Instance()->CreateAsyncTcpClient();
#else
tcp_client_ = new a8::TcpClient();
#endif
tcp_client_->remote_address = remote_ip;
tcp_client_->remote_port = remote_port;
tcp_client_->on_error = std::bind(&TargetConn::on_error, this, std::placeholders::_1, std::placeholders::_2);
@ -62,11 +58,7 @@ void TargetConn::UnInit()
a8::Timer::Instance()->DeleteTimer(timer_);
timer_ = nullptr;
tcp_client_->Close();
#if ASYNC_TCPCLIENT && GAME_ID == 2002
a8::IoLoop::Instance()->DestoryAsyncTcpClient(tcp_client_);
#else
delete tcp_client_;
#endif
tcp_client_ = nullptr;
recv_bufflen_ = 0;
free(recv_buff_);
@ -152,11 +144,7 @@ void TargetConn::ForwardClientMsgEx(f8::MsgHdr* hdr)
}
}
#if ASYNC_TCPCLIENT && GAME_ID == 2002
void TargetConn::on_error(a8::AsyncTcpClient* sender, int errorId)
#else
void TargetConn::on_error(a8::TcpClient* sender, int errorId)
#endif
{
a8::UdpLog::Instance()->Error("target server errorid=%d remote_ip:%s remote_port:%d",
{
@ -166,11 +154,7 @@ void TargetConn::on_error(a8::TcpClient* sender, int errorId)
});
}
#if ASYNC_TCPCLIENT && GAME_ID == 2002
void TargetConn::on_connect(a8::AsyncTcpClient* sender)
#else
void TargetConn::on_connect(a8::TcpClient* sender)
#endif
{
recv_bufflen_ = 0;
a8::UdpLog::Instance()->Info("target server connected remote_ip:%s remote_port:%d",
@ -184,11 +168,7 @@ void TargetConn::on_connect(a8::TcpClient* sender)
);
}
#if ASYNC_TCPCLIENT && GAME_ID == 2002
void TargetConn::on_disconnect(a8::AsyncTcpClient* sender)
#else
void TargetConn::on_disconnect(a8::TcpClient* sender)
#endif
{
recv_bufflen_ = 0;
a8::UdpLog::Instance()->Info("target server %d disconnected after 10s later reconnect "
@ -204,11 +184,7 @@ void TargetConn::on_disconnect(a8::TcpClient* sender)
);
}
#if ASYNC_TCPCLIENT && GAME_ID == 2002
void TargetConn::on_socketread(a8::AsyncTcpClient* sender, char* buf, unsigned int len)
#else
void TargetConn::on_socketread(a8::TcpClient* sender, char* buf, unsigned int len)
#endif
{
#if 0
++App::Instance()->perf.read_count;

View File

@ -56,17 +56,10 @@ class TargetConn
void ForwardClientMsgEx(f8::MsgHdr* hdr);
private:
#if ASYNC_TCPCLIENT && GAME_ID == 2002
void on_error(a8::AsyncTcpClient* sender, int errorId);
void on_connect(a8::AsyncTcpClient* sender);
void on_disconnect(a8::AsyncTcpClient* sender);
void on_socketread(a8::AsyncTcpClient* sender, char* buf, unsigned int len);
#else
void on_error(a8::TcpClient* sender, int errorId);
void on_connect(a8::TcpClient* sender);
void on_disconnect(a8::TcpClient* sender);
void on_socketread(a8::TcpClient* sender, char* buf, unsigned int len);
#endif
void CheckAlive();
void AddStockMsg(unsigned short socket_handle, int msgid, ::google::protobuf::Message* msg,
@ -75,11 +68,7 @@ class TargetConn
private:
char *recv_buff_ = nullptr;
unsigned int recv_bufflen_ = 0;
#if ASYNC_TCPCLIENT && GAME_ID == 2002
a8::AsyncTcpClient* tcp_client_ = nullptr;
#else
a8::TcpClient* tcp_client_ = nullptr;
#endif
timer_list* timer_ = nullptr;
TargetConnMsgNode* top_node_ = nullptr;