1
This commit is contained in:
parent
746c982fab
commit
0c214177a4
@ -65,7 +65,6 @@ static void SavePerfLog()
|
|||||||
App::Instance()->perf.max_login_time,
|
App::Instance()->perf.max_login_time,
|
||||||
App::Instance()->perf.max_join_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 "
|
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 "
|
" shutdown_times:%d connect_times:%d close_times:%d "
|
||||||
" send_times:%d recv_times:%d error_times:%d immsg_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()->error_times,
|
||||||
(long long)a8::IoLoop::Instance()->immsg_times
|
(long long)a8::IoLoop::Instance()->immsg_times
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
if (App::Instance()->HasFlag(2)) {
|
if (App::Instance()->HasFlag(2)) {
|
||||||
a8::XPrintf("mainloop_time:%d netmsg_time:%d send_node_num:%d sent_bytes_num:%d\n",
|
a8::XPrintf("mainloop_time:%d netmsg_time:%d send_node_num:%d sent_bytes_num:%d\n",
|
||||||
{
|
{
|
||||||
|
@ -23,11 +23,7 @@ void MasterSvr::Init(int instance_id, const std::string& remote_ip, int remote_p
|
|||||||
recv_bufflen_ = 0;
|
recv_bufflen_ = 0;
|
||||||
last_pong_tick = a8::XGetTickCount();
|
last_pong_tick = a8::XGetTickCount();
|
||||||
recv_buff_ = (char*) malloc(PACK_MAX * 2);
|
recv_buff_ = (char*) malloc(PACK_MAX * 2);
|
||||||
#if ASYNC_TCPCLIENT
|
|
||||||
tcp_client_ = a8::IoLoop::Instance()->CreateAsyncTcpClient();
|
tcp_client_ = a8::IoLoop::Instance()->CreateAsyncTcpClient();
|
||||||
#else
|
|
||||||
tcp_client_ = new a8::TcpClient();
|
|
||||||
#endif
|
|
||||||
tcp_client_->remote_address = remote_ip;
|
tcp_client_->remote_address = remote_ip;
|
||||||
tcp_client_->remote_port = remote_port;
|
tcp_client_->remote_port = remote_port;
|
||||||
tcp_client_->on_error = std::bind(&MasterSvr::on_error, this, std::placeholders::_1, std::placeholders::_2);
|
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_);
|
a8::Timer::Instance()->DeleteTimer(timer_);
|
||||||
timer_ = nullptr;
|
timer_ = nullptr;
|
||||||
tcp_client_->Close();
|
tcp_client_->Close();
|
||||||
#if ASYNC_TCPCLIENT
|
|
||||||
a8::IoLoop::Instance()->DestoryAsyncTcpClient(tcp_client_);
|
a8::IoLoop::Instance()->DestoryAsyncTcpClient(tcp_client_);
|
||||||
#else
|
|
||||||
delete tcp_client_;
|
|
||||||
#endif
|
|
||||||
tcp_client_ = nullptr;
|
tcp_client_ = nullptr;
|
||||||
recv_bufflen_ = 0;
|
recv_bufflen_ = 0;
|
||||||
free(recv_buff_);
|
free(recv_buff_);
|
||||||
@ -74,11 +66,7 @@ bool MasterSvr::Connected()
|
|||||||
return tcp_client_->Connected();
|
return tcp_client_->Connected();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ASYNC_TCPCLIENT
|
|
||||||
void MasterSvr::on_error(a8::AsyncTcpClient* sender, int errorId)
|
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",
|
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)
|
void MasterSvr::on_connect(a8::AsyncTcpClient* sender)
|
||||||
#else
|
|
||||||
void MasterSvr::on_connect(a8::TcpClient* sender)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
recv_bufflen_ = 0;
|
recv_bufflen_ = 0;
|
||||||
a8::UdpLog::Instance()->Info("masterserver connected", {});
|
a8::UdpLog::Instance()->Info("masterserver connected", {});
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ASYNC_TCPCLIENT
|
|
||||||
void MasterSvr::on_disconnect(a8::AsyncTcpClient* sender)
|
void MasterSvr::on_disconnect(a8::AsyncTcpClient* sender)
|
||||||
#else
|
|
||||||
void MasterSvr::on_disconnect(a8::TcpClient* sender)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
recv_bufflen_ = 0;
|
recv_bufflen_ = 0;
|
||||||
a8::UdpLog::Instance()->Info("masterserver %d disconnected after 10s later reconnect", {instance_id});
|
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)
|
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
|
#if 0
|
||||||
++App::Instance()->perf.read_count;
|
++App::Instance()->perf.read_count;
|
||||||
|
@ -33,27 +33,16 @@ class MasterSvr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if ASYNC_TCPCLIENT
|
|
||||||
void on_error(a8::AsyncTcpClient* sender, int errorId);
|
void on_error(a8::AsyncTcpClient* sender, int errorId);
|
||||||
void on_connect(a8::AsyncTcpClient* sender);
|
void on_connect(a8::AsyncTcpClient* sender);
|
||||||
void on_disconnect(a8::AsyncTcpClient* sender);
|
void on_disconnect(a8::AsyncTcpClient* sender);
|
||||||
void on_socketread(a8::AsyncTcpClient* sender, char* buf, unsigned int len);
|
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 CheckAlive();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *recv_buff_ = nullptr;
|
char *recv_buff_ = nullptr;
|
||||||
unsigned int recv_bufflen_ = 0;
|
unsigned int recv_bufflen_ = 0;
|
||||||
#if ASYNC_TCPCLIENT
|
|
||||||
a8::AsyncTcpClient* tcp_client_ = nullptr;
|
a8::AsyncTcpClient* tcp_client_ = nullptr;
|
||||||
#else
|
|
||||||
a8::TcpClient* tcp_client_ = nullptr;
|
|
||||||
#endif
|
|
||||||
timer_list* timer_ = nullptr;
|
timer_list* timer_ = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -26,11 +26,7 @@ void TargetConn::Init(int instance_id, const std::string& remote_ip, int remote_
|
|||||||
recv_bufflen_ = 0;
|
recv_bufflen_ = 0;
|
||||||
last_pong_tick = a8::XGetTickCount();
|
last_pong_tick = a8::XGetTickCount();
|
||||||
recv_buff_ = (char*) malloc(PACK_MAX * 2);
|
recv_buff_ = (char*) malloc(PACK_MAX * 2);
|
||||||
#if ASYNC_TCPCLIENT && GAME_ID == 2002
|
|
||||||
tcp_client_ = a8::IoLoop::Instance()->CreateAsyncTcpClient();
|
tcp_client_ = a8::IoLoop::Instance()->CreateAsyncTcpClient();
|
||||||
#else
|
|
||||||
tcp_client_ = new a8::TcpClient();
|
|
||||||
#endif
|
|
||||||
tcp_client_->remote_address = remote_ip;
|
tcp_client_->remote_address = remote_ip;
|
||||||
tcp_client_->remote_port = remote_port;
|
tcp_client_->remote_port = remote_port;
|
||||||
tcp_client_->on_error = std::bind(&TargetConn::on_error, this, std::placeholders::_1, std::placeholders::_2);
|
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_);
|
a8::Timer::Instance()->DeleteTimer(timer_);
|
||||||
timer_ = nullptr;
|
timer_ = nullptr;
|
||||||
tcp_client_->Close();
|
tcp_client_->Close();
|
||||||
#if ASYNC_TCPCLIENT && GAME_ID == 2002
|
|
||||||
a8::IoLoop::Instance()->DestoryAsyncTcpClient(tcp_client_);
|
a8::IoLoop::Instance()->DestoryAsyncTcpClient(tcp_client_);
|
||||||
#else
|
|
||||||
delete tcp_client_;
|
|
||||||
#endif
|
|
||||||
tcp_client_ = nullptr;
|
tcp_client_ = nullptr;
|
||||||
recv_bufflen_ = 0;
|
recv_bufflen_ = 0;
|
||||||
free(recv_buff_);
|
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)
|
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",
|
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)
|
void TargetConn::on_connect(a8::AsyncTcpClient* sender)
|
||||||
#else
|
|
||||||
void TargetConn::on_connect(a8::TcpClient* sender)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
recv_bufflen_ = 0;
|
recv_bufflen_ = 0;
|
||||||
a8::UdpLog::Instance()->Info("target server connected remote_ip:%s remote_port:%d",
|
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)
|
void TargetConn::on_disconnect(a8::AsyncTcpClient* sender)
|
||||||
#else
|
|
||||||
void TargetConn::on_disconnect(a8::TcpClient* sender)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
recv_bufflen_ = 0;
|
recv_bufflen_ = 0;
|
||||||
a8::UdpLog::Instance()->Info("target server %d disconnected after 10s later reconnect "
|
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)
|
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
|
#if 0
|
||||||
++App::Instance()->perf.read_count;
|
++App::Instance()->perf.read_count;
|
||||||
|
@ -56,17 +56,10 @@ class TargetConn
|
|||||||
void ForwardClientMsgEx(f8::MsgHdr* hdr);
|
void ForwardClientMsgEx(f8::MsgHdr* hdr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if ASYNC_TCPCLIENT && GAME_ID == 2002
|
|
||||||
void on_error(a8::AsyncTcpClient* sender, int errorId);
|
void on_error(a8::AsyncTcpClient* sender, int errorId);
|
||||||
void on_connect(a8::AsyncTcpClient* sender);
|
void on_connect(a8::AsyncTcpClient* sender);
|
||||||
void on_disconnect(a8::AsyncTcpClient* sender);
|
void on_disconnect(a8::AsyncTcpClient* sender);
|
||||||
void on_socketread(a8::AsyncTcpClient* sender, char* buf, unsigned int len);
|
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 CheckAlive();
|
||||||
void AddStockMsg(unsigned short socket_handle, int msgid, ::google::protobuf::Message* msg,
|
void AddStockMsg(unsigned short socket_handle, int msgid, ::google::protobuf::Message* msg,
|
||||||
@ -75,11 +68,7 @@ class TargetConn
|
|||||||
private:
|
private:
|
||||||
char *recv_buff_ = nullptr;
|
char *recv_buff_ = nullptr;
|
||||||
unsigned int recv_bufflen_ = 0;
|
unsigned int recv_bufflen_ = 0;
|
||||||
#if ASYNC_TCPCLIENT && GAME_ID == 2002
|
|
||||||
a8::AsyncTcpClient* tcp_client_ = nullptr;
|
a8::AsyncTcpClient* tcp_client_ = nullptr;
|
||||||
#else
|
|
||||||
a8::TcpClient* tcp_client_ = nullptr;
|
|
||||||
#endif
|
|
||||||
timer_list* timer_ = nullptr;
|
timer_list* timer_ = nullptr;
|
||||||
|
|
||||||
TargetConnMsgNode* top_node_ = nullptr;
|
TargetConnMsgNode* top_node_ = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user