72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
#include "precompile.h"
|
|
|
|
#include <a8/udplistener.h>
|
|
|
|
#include <f8/udplog.h>
|
|
|
|
#include "longsessionmgr.h"
|
|
#include "app.h"
|
|
#include "jsondatamgr.h"
|
|
|
|
static void GSUdpListeneron_error(int errorid)
|
|
{
|
|
f8::UdpLog::Instance()->Debug("GCUdpListeneron_error %d", {errorid});
|
|
}
|
|
|
|
static void GSUdpListeneron_recv_packet(a8::UdpPacket* pkt)
|
|
{
|
|
App::Instance()->AddUdpMsg(pkt);
|
|
}
|
|
|
|
void LongSessionMgr::Init()
|
|
{
|
|
udp_listener_ = std::make_shared<a8::UdpListener>();
|
|
udp_listener_->on_error = GSUdpListeneron_error;
|
|
udp_listener_->on_recv_packet = GSUdpListeneron_recv_packet;
|
|
|
|
udp_listener_->bind_address = "0.0.0.0";
|
|
udp_listener_->bind_port = JsonDataMgr::Instance()->GetConf()->At("listen_udp_port")->AsXValue();
|
|
udp_listener_->Open();
|
|
}
|
|
|
|
void LongSessionMgr::UnInit()
|
|
{
|
|
|
|
}
|
|
|
|
void LongSessionMgr::Update()
|
|
{
|
|
|
|
}
|
|
|
|
std::shared_ptr<LongSession> GetSessionBySocketHandle(int socket_handle)
|
|
{
|
|
return 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)
|
|
{
|
|
#if 0
|
|
long long key = pkt->GetRemoteKey();
|
|
auto session = GetKcpSessionByRemoteKey(key);
|
|
if (session) {
|
|
session->OnRecvPacket(pkt);
|
|
}
|
|
#endif
|
|
}
|