1
This commit is contained in:
parent
9ae217eea5
commit
52188b8ada
@ -13,6 +13,8 @@ void DownStream::Init(int socket_handle, std::weak_ptr<UpStream> up)
|
||||
{
|
||||
socket_handle_ = socket_handle;
|
||||
up_ = up;
|
||||
long_session_wp_ = LongSessionMgr::Instance()->GetSession(socket_handle_);
|
||||
is_long_session_ = !long_session_wp_.expired();
|
||||
}
|
||||
|
||||
void DownStream::ReBindUpStream(std::weak_ptr<UpStream> up)
|
||||
@ -33,9 +35,8 @@ void DownStream::ForwardUpStreamMsg(f8::MsgHdr& hdr)
|
||||
memmove(buff + sizeof(f8::PackHead), hdr.buf, hdr.buflen);
|
||||
}
|
||||
|
||||
auto session = LongSessionMgr::Instance()->GetSession(hdr.socket_handle);
|
||||
if (session) {
|
||||
session->GetKcpSession()->SendClientMsg(buff, sizeof(f8::PackHead) + head->packlen);
|
||||
if (auto long_session = long_session_wp_.lock(); !long_session_wp_.expired()) {
|
||||
long_session->GetKcpSession()->SendClientMsg(buff, sizeof(f8::PackHead) + head->packlen);
|
||||
} else {
|
||||
GCListener::Instance()->SendBuf(hdr.socket_handle, buff, sizeof(f8::PackHead) + head->packlen);
|
||||
}
|
||||
@ -48,8 +49,7 @@ void DownStream::OnClose()
|
||||
ss::SS_WSP_SocketDisconnect msg;
|
||||
GetUpStream().lock()->SendMsg(socket_handle_, msg);
|
||||
}
|
||||
auto session = LongSessionMgr::Instance()->GetSession(socket_handle_);
|
||||
if (session) {
|
||||
if (auto long_session = long_session_wp_.lock(); !long_session_wp_.expired()) {
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
class UpStream;
|
||||
class LongSession;
|
||||
class DownStream
|
||||
{
|
||||
public:
|
||||
@ -17,4 +18,6 @@ class DownStream
|
||||
private:
|
||||
int socket_handle_ = a8::INVALID_SOCKET_HANDLE;
|
||||
std::weak_ptr<UpStream> up_;
|
||||
bool is_long_session_ = false;
|
||||
std::weak_ptr<LongSession> long_session_wp_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user