This commit is contained in:
aozhiwei 2023-04-23 16:33:44 +08:00
parent a968685105
commit 4ad5bbdc1e

View File

@ -7,6 +7,7 @@
#include "longsessionmgr.h" #include "longsessionmgr.h"
#include "app.h" #include "app.h"
#include "jsondatamgr.h" #include "jsondatamgr.h"
#include "longsession.h"
static void GSUdpListeneron_error(int errorid) static void GSUdpListeneron_error(int errorid)
{ {
@ -39,33 +40,20 @@ void LongSessionMgr::Update()
} }
std::shared_ptr<LongSession> GetSessionBySocketHandle(int socket_handle) std::shared_ptr<LongSession> LongSessionMgr::GetSession(int socket_handle)
{ {
return nullptr; auto itr = socket_handle_hash_.find(socket_handle);
return itr != socket_handle_hash_.end() ? itr->second : nullptr;
} }
#if 0
std::shared_ptr<KcpSession> GCListener::GetKcpSessionByRemoteKey(long long key)
{
auto itr = kcp_session_addr_hash_.find(key);
return itr != kcp_session_addr_hash_.end() ? itr->second : nullptr;
}
std::shared_ptr<KcpSession> GCListener::GetKcpSessionBySocketHandle(int socket_handle)
{
auto itr = kcp_session_handle_hash_.find(socket_handle);
return itr != kcp_session_handle_hash_.end() ? itr->second : nullptr;
}
#endif
void LongSessionMgr::ProcUdpPacket(a8::UdpPacket* pkt) void LongSessionMgr::ProcUdpPacket(a8::UdpPacket* pkt)
{ {
int socket_handle = 0;
long long secret_key = 0;
auto session = GetSession(socket_handle);
if (session && secret_key == session->GetSecretKey()) {
#if 0 #if 0
long long key = pkt->GetRemoteKey();
auto session = GetKcpSessionByRemoteKey(key);
if (session) {
session->OnRecvPacket(pkt); session->OnRecvPacket(pkt);
}
#endif #endif
}
} }