1
This commit is contained in:
parent
5da25c735d
commit
499114b744
@ -441,14 +441,7 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr, int tag)
|
|||||||
} else {
|
} else {
|
||||||
auto down_wp = DownStreamMgr::Instance()->GetDownStream(hdr.socket_handle);
|
auto down_wp = DownStreamMgr::Instance()->GetDownStream(hdr.socket_handle);
|
||||||
if (auto down = down_wp.lock(); !down_wp.expired()) {
|
if (auto down = down_wp.lock(); !down_wp.expired()) {
|
||||||
bool need_sync_up = true;
|
down->ProcCMMsg(hdr, tag);
|
||||||
#if 0
|
|
||||||
if (hdr.msgid == ss::_SS_CMPing && down->IsLongSession()) {
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!down->GetUpStream().expired() && need_sync_up) {
|
|
||||||
down->GetUpStream().lock()->ForwardClientMsg(hdr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "longsession.h"
|
#include "longsession.h"
|
||||||
#include "kcpsession.h"
|
#include "kcpsession.h"
|
||||||
|
|
||||||
|
#include "ss_msgid.pb.h"
|
||||||
#include "ss_proto.pb.h"
|
#include "ss_proto.pb.h"
|
||||||
|
|
||||||
void DownStream::Init(int socket_handle, std::weak_ptr<UpStream> up)
|
void DownStream::Init(int socket_handle, std::weak_ptr<UpStream> up)
|
||||||
@ -53,3 +54,18 @@ void DownStream::OnClose()
|
|||||||
LongSessionMgr::Instance()->DelSession(socket_handle_);
|
LongSessionMgr::Instance()->DelSession(socket_handle_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DownStream::ProcCMMsg(f8::MsgHdr& hdr, int tag)
|
||||||
|
{
|
||||||
|
if (hdr.msgid == ss::_SS_CMPing && IsLongSession() && tag == ST_Tcp) {
|
||||||
|
ss::SS_Ping msg;
|
||||||
|
GCListener::Instance()->SendMsgEx(socket_handle_, ss::_SS_CMPing, msg);
|
||||||
|
if (!long_session_wp_.expired()) {
|
||||||
|
long_session_wp_.lock()->UpdatePing();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!GetUpStream().expired()) {
|
||||||
|
GetUpStream().lock()->ForwardClientMsg(hdr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -12,6 +12,7 @@ class DownStream
|
|||||||
std::weak_ptr<UpStream> GetUpStream() const { return up_; }
|
std::weak_ptr<UpStream> GetUpStream() const { return up_; }
|
||||||
void ReBindUpStream(std::weak_ptr<UpStream> up);
|
void ReBindUpStream(std::weak_ptr<UpStream> up);
|
||||||
bool IsLongSession() { return is_long_session_; }
|
bool IsLongSession() { return is_long_session_; }
|
||||||
|
void ProcCMMsg(f8::MsgHdr& hdr, int tag);
|
||||||
|
|
||||||
void ForwardUpStreamMsg(f8::MsgHdr& hdr);
|
void ForwardUpStreamMsg(f8::MsgHdr& hdr);
|
||||||
void OnClose();
|
void OnClose();
|
||||||
|
@ -20,3 +20,8 @@ void LongSession::Update(long long tick)
|
|||||||
{
|
{
|
||||||
GetKcpSession()->Update(tick);
|
GetKcpSession()->Update(tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LongSession::UpdatePing()
|
||||||
|
{
|
||||||
|
last_ping_tick_ = a8::XGetTickCount();
|
||||||
|
}
|
||||||
|
@ -16,7 +16,9 @@ class LongSession
|
|||||||
void Update(long long tick);
|
void Update(long long tick);
|
||||||
|
|
||||||
std::shared_ptr<KcpSession> GetKcpSession() { return kcp_session_; }
|
std::shared_ptr<KcpSession> GetKcpSession() { return kcp_session_; }
|
||||||
|
void UpdatePing();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
long long last_ping_tick_ = 0;
|
||||||
std::shared_ptr<KcpSession> kcp_session_;
|
std::shared_ptr<KcpSession> kcp_session_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user