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;
|
socket_handle_ = socket_handle;
|
||||||
up_ = up;
|
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)
|
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);
|
memmove(buff + sizeof(f8::PackHead), hdr.buf, hdr.buflen);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto session = LongSessionMgr::Instance()->GetSession(hdr.socket_handle);
|
if (auto long_session = long_session_wp_.lock(); !long_session_wp_.expired()) {
|
||||||
if (session) {
|
long_session->GetKcpSession()->SendClientMsg(buff, sizeof(f8::PackHead) + head->packlen);
|
||||||
session->GetKcpSession()->SendClientMsg(buff, sizeof(f8::PackHead) + head->packlen);
|
|
||||||
} else {
|
} else {
|
||||||
GCListener::Instance()->SendBuf(hdr.socket_handle, buff, sizeof(f8::PackHead) + head->packlen);
|
GCListener::Instance()->SendBuf(hdr.socket_handle, buff, sizeof(f8::PackHead) + head->packlen);
|
||||||
}
|
}
|
||||||
@ -48,8 +49,7 @@ void DownStream::OnClose()
|
|||||||
ss::SS_WSP_SocketDisconnect msg;
|
ss::SS_WSP_SocketDisconnect msg;
|
||||||
GetUpStream().lock()->SendMsg(socket_handle_, msg);
|
GetUpStream().lock()->SendMsg(socket_handle_, msg);
|
||||||
}
|
}
|
||||||
auto session = LongSessionMgr::Instance()->GetSession(socket_handle_);
|
if (auto long_session = long_session_wp_.lock(); !long_session_wp_.expired()) {
|
||||||
if (session) {
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class UpStream;
|
class UpStream;
|
||||||
|
class LongSession;
|
||||||
class DownStream
|
class DownStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -17,4 +18,6 @@ class DownStream
|
|||||||
private:
|
private:
|
||||||
int socket_handle_ = a8::INVALID_SOCKET_HANDLE;
|
int socket_handle_ = a8::INVALID_SOCKET_HANDLE;
|
||||||
std::weak_ptr<UpStream> up_;
|
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