From 68bc02f627ef438350aad66c55f245153fe1e04c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 11 Dec 2019 14:49:24 +0800 Subject: [PATCH] 1 --- server/wsproxy/mastersvrmgr.cc | 59 +++++++++++++++++++++++++--------- third_party/a8engine | 2 +- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/server/wsproxy/mastersvrmgr.cc b/server/wsproxy/mastersvrmgr.cc index fa9c8cb..605b7dd 100644 --- a/server/wsproxy/mastersvrmgr.cc +++ b/server/wsproxy/mastersvrmgr.cc @@ -15,6 +15,8 @@ #include "framework/cpp/netmsghandler.h" +const char* azw_account_id = "6001_2001_oJqfX5c4pvW-wlarmcrvEO6BQjd8"; + void MasterSvrMgr::Init() { curr_context_id_ = a8::MakeInt64(0, time(nullptr) + 1000 * 60 * 10); @@ -56,11 +58,6 @@ void MasterSvrMgr::_SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_ auto_free = false; conn->ForwardClientMsgEx(context_hdr); } - long long req_tick = (long long)hdr.hum; - long long req_handle_time = a8::XGetTickCount() - req_tick; - if (req_handle_time > App::Instance()->perf.max_login_time) { - App::Instance()->perf.max_login_time = req_handle_time; - } } RemoveRequest(socket_handle, msg.context_id(), auto_free); } @@ -98,7 +95,6 @@ void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_ a8::TimerAttacher* timer_attacher = new a8::TimerAttacher(); f8::MsgHdr* new_hdr = hdr.Clone(); new_hdr->user_data = timer_attacher; - new_hdr->hum = (Player*)a8::XGetTickCount(); ss::SS_WSP_RequestTargetServer msg; msg.set_context_id(curr_context_id_); @@ -108,19 +104,50 @@ void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_ pending_socket_hash_[hdr.socket_handle] = curr_context_id_; assert(pending_request_hash_.find(curr_context_id_) == pending_request_hash_.end()); pending_request_hash_[curr_context_id_] = new_hdr; + if (account_id == azw_account_id) { + a8::UdpLog::Instance()->Info("%s request", {account_id}); + } + auto timer_func = + [] (const a8::XParams& param) + { + if (param.param2.GetString() == azw_account_id) { + a8::UdpLog::Instance()->Info("%s timeout", + { + param.param2.GetString() + }); + } + a8::Timer::Instance()->RemoveTimerFunc(a8::Timer::Instance()->GetRunningTimer()); + MasterSvrMgr::Instance()->RemoveRequest( + param.param1, + param.sender, + true + ); + }; + auto timer_after_func = + [] (const a8::XParams& param) + { + if (param.param2.GetString() == azw_account_id) { + a8::UdpLog::Instance()->Info("%s response time:%d", + { + param.param2.GetString(), + a8::XGetTickCount() - param.param3.GetInt64() + }); + } + long long req_handle_time = a8::XGetTickCount() - param.param3.GetInt64(); + if (req_handle_time > App::Instance()->perf.max_login_time) { + App::Instance()->perf.max_login_time = req_handle_time; + } + }; a8::Timer::Instance()->AddDeadLineTimerAndAttach(1000 * 10, a8::XParams() .SetSender(curr_context_id_) - .SetParam1(hdr.socket_handle), - [] (const a8::XParams& param) - { - MasterSvrMgr::Instance()->RemoveRequest( - param.param1, - param.sender, - true - ); - }, - &timer_attacher->timer_list_); + .SetParam1(hdr.socket_handle) + .SetParam2(account_id) + .SetParam3(a8::XGetTickCount()), + timer_func, + &timer_attacher->timer_list_, + timer_after_func + ); } } diff --git a/third_party/a8engine b/third_party/a8engine index 9a8d93e..cd38d3a 160000 --- a/third_party/a8engine +++ b/third_party/a8engine @@ -1 +1 @@ -Subproject commit 9a8d93e085ee2ce420010501c2a1397aece62269 +Subproject commit cd38d3a5ff77831d675fd7accd90a38992a294c8