diff --git a/server/wsproxy/GCListener.cc b/server/wsproxy/GCListener.cc index 454d5ce..d3c3220 100644 --- a/server/wsproxy/GCListener.cc +++ b/server/wsproxy/GCListener.cc @@ -37,7 +37,8 @@ public: p->msgid, p->seqid, &buf[offset + sizeof(f8::PackHead)], - p->packlen); + p->packlen, + ST_Tcp); offset += sizeof(f8::PackHead) + p->packlen; } else { warning = true; diff --git a/server/wsproxy/app.cc b/server/wsproxy/app.cc index dea8306..a5f2b11 100644 --- a/server/wsproxy/app.cc +++ b/server/wsproxy/app.cc @@ -40,6 +40,7 @@ struct MsgNode long ip_saddr; char* buf; int buflen; + int tag; MsgNode* next; }; @@ -227,7 +228,8 @@ void App::AddSocketMsg(SocketFrom_e sockfrom, unsigned short msgid, unsigned int seqid, const char *msgbody, - int bodylen) + int bodylen, + int tag) { MsgNode *p = (MsgNode*)malloc(sizeof(MsgNode)); memset(p, 0, sizeof(MsgNode)); @@ -238,6 +240,7 @@ void App::AddSocketMsg(SocketFrom_e sockfrom, p->seqid = seqid; p->buf = nullptr; p->buflen = bodylen; + p->tag = tag; if (bodylen > 0) { p->buf = (char*)malloc(bodylen); memmove(p->buf, msgbody, bodylen); @@ -350,17 +353,17 @@ void App::DispatchMsg() switch (pdelnode->sockfrom) { case SF_Client: { - ProcessClientMsg(hdr); + ProcessClientMsg(hdr, pdelnode->tag); } break; case SF_TargetServer: { - ProcessTargetServerMsg(hdr); + ProcessTargetServerMsg(hdr, pdelnode->tag); } break; case SF_MasterServer: { - ProcessMasterServerMsg(hdr); + ProcessMasterServerMsg(hdr, pdelnode->tag); } break; } @@ -379,7 +382,7 @@ void App::DispatchMsg() } } -void App::ProcessClientMsg(f8::MsgHdr& hdr) +void App::ProcessClientMsg(f8::MsgHdr& hdr, int tag) { if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReconnect || @@ -438,14 +441,19 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr) } else { auto down_wp = DownStreamMgr::Instance()->GetDownStream(hdr.socket_handle); if (auto down = down_wp.lock(); !down_wp.expired()) { - if (!down->GetUpStream().expired()) { + bool need_sync_up = true; + #if 0 + if (hdr.msgid == ss::_SS_CMPing && down->IsLongSession()) { + } + #endif + if (!down->GetUpStream().expired() && need_sync_up) { down->GetUpStream().lock()->ForwardClientMsg(hdr); } } } } -void App::ProcessMasterServerMsg(f8::MsgHdr& hdr) +void App::ProcessMasterServerMsg(f8::MsgHdr& hdr, int tag) { f8::NetMsgHandler* handler = f8::GetNetMsgHandler(&HandlerMgr::Instance()->msmsghandler, hdr.msgid); @@ -458,7 +466,7 @@ void App::ProcessMasterServerMsg(f8::MsgHdr& hdr) } } -void App::ProcessTargetServerMsg(f8::MsgHdr& hdr) +void App::ProcessTargetServerMsg(f8::MsgHdr& hdr, int tag) { if (hdr.msgid == ss::_SS_ForceCloseSocket) { GCListener::Instance()->ForceCloseClient(hdr.socket_handle); diff --git a/server/wsproxy/app.h b/server/wsproxy/app.h index bd5ab37..34ca64b 100644 --- a/server/wsproxy/app.h +++ b/server/wsproxy/app.h @@ -32,7 +32,8 @@ public: unsigned short msgid, unsigned int seqid, const char *msgbody, - int bodylen); + int bodylen, + int tag = ST_Tcp); void AddUdpMsg(a8::UdpPacket* pkt); @@ -54,9 +55,9 @@ private: void DispatchMsg(); void DispatchUdpMsg(); - void ProcessClientMsg(f8::MsgHdr& hdr); - void ProcessMasterServerMsg(f8::MsgHdr& hdr); - void ProcessTargetServerMsg(f8::MsgHdr& hdr); + void ProcessClientMsg(f8::MsgHdr& hdr, int tag); + void ProcessMasterServerMsg(f8::MsgHdr& hdr, int tag); + void ProcessTargetServerMsg(f8::MsgHdr& hdr, int tag); void InitLog(); void UnInitLog(); diff --git a/server/wsproxy/constant.h b/server/wsproxy/constant.h index 92a0b17..8b27483 100644 --- a/server/wsproxy/constant.h +++ b/server/wsproxy/constant.h @@ -7,6 +7,12 @@ enum SocketFrom_e SF_MasterServer, }; +enum SocketTag_e +{ + ST_Tcp = 1, + ST_Udp, +}; + enum InnerMesssage_e { IM_ClientSocketDisconnect = 100, diff --git a/server/wsproxy/downstream.h b/server/wsproxy/downstream.h index 20975e8..196fa09 100644 --- a/server/wsproxy/downstream.h +++ b/server/wsproxy/downstream.h @@ -11,6 +11,7 @@ class DownStream int GetSocketHandle() const { return socket_handle_; } std::weak_ptr GetUpStream() const { return up_; } void ReBindUpStream(std::weak_ptr up); + bool IsLongSession() { return is_long_session_; } void ForwardUpStreamMsg(f8::MsgHdr& hdr); void OnClose(); diff --git a/server/wsproxy/kcpsession.cc b/server/wsproxy/kcpsession.cc index 366d936..c52e9e8 100644 --- a/server/wsproxy/kcpsession.cc +++ b/server/wsproxy/kcpsession.cc @@ -99,7 +99,8 @@ void KcpSession::DecodeUserPacket(char* buf, int& offset, unsigned int buflen) p->msgid, p->seqid, &buf[offset + sizeof(f8::PackHead) + GetSecretKeyLen()], - p->packlen); + p->packlen, + ST_Udp); offset += sizeof(f8::PackHead) + p->packlen + GetSecretKeyLen(); } else { warning = true;