1
This commit is contained in:
parent
5a051c97cc
commit
45af072c80
@ -58,24 +58,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",
|
||||
{
|
||||
(long long)a8::IoLoop::Instance()->run_times,
|
||||
(long long)a8::IoLoop::Instance()->timer_times,
|
||||
(long long)a8::IoLoop::Instance()->event_times,
|
||||
(long long)a8::IoLoop::Instance()->free_times,
|
||||
(long long)a8::IoLoop::Instance()->shutdown_times,
|
||||
(long long)a8::IoLoop::Instance()->connect_times,
|
||||
(long long)a8::IoLoop::Instance()->close_times,
|
||||
(long long)a8::IoLoop::Instance()->send_times,
|
||||
(long long)a8::IoLoop::Instance()->recv_times,
|
||||
(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",
|
||||
{
|
||||
|
@ -24,11 +24,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);
|
||||
@ -53,11 +49,7 @@ void MasterSvr::UnInit()
|
||||
timer_ = nullptr;
|
||||
#endif
|
||||
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_);
|
||||
@ -79,11 +71,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
|
||||
{
|
||||
f8::UdpLog::Instance()->Error("MasterSvr errorid=%d remote_ip:%s remote_port:%d",
|
||||
{
|
||||
@ -93,21 +81,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;
|
||||
f8::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;
|
||||
f8::UdpLog::Instance()->Info("masterserver %d disconnected after 10s later reconnect", {instance_id});
|
||||
@ -119,11 +99,7 @@ void MasterSvr::on_disconnect(a8::TcpClient* sender)
|
||||
#endif
|
||||
}
|
||||
|
||||
#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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -27,11 +27,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);
|
||||
@ -67,11 +63,7 @@ void TargetConn::UnInit()
|
||||
timer_ = nullptr;
|
||||
#endif
|
||||
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_);
|
||||
@ -157,11 +149,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
|
||||
{
|
||||
f8::UdpLog::Instance()->Error("target server errorid=%d remote_ip:%s remote_port:%d",
|
||||
{
|
||||
@ -171,11 +159,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;
|
||||
f8::UdpLog::Instance()->Info("target server connected remote_ip:%s remote_port:%d",
|
||||
@ -191,11 +175,7 @@ void TargetConn::on_connect(a8::TcpClient* sender)
|
||||
#endif
|
||||
}
|
||||
|
||||
#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;
|
||||
f8::UdpLog::Instance()->Info("target server %d disconnected after 10s later reconnect "
|
||||
@ -213,11 +193,7 @@ void TargetConn::on_disconnect(a8::TcpClient* sender)
|
||||
#endif
|
||||
}
|
||||
|
||||
#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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user