1
This commit is contained in:
parent
21d2504eac
commit
f856b632ba
@ -129,13 +129,26 @@ class KcpSession
|
||||
{
|
||||
public:
|
||||
|
||||
void Init(a8::UdpPacket* pkt)
|
||||
{
|
||||
remote_key_ = pkt->GetRemoteKey();
|
||||
remote_addr_ = pkt->remote_addr;
|
||||
}
|
||||
|
||||
void SendMsg(unsigned short msgid, const ::google::protobuf::Message& msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnRecvPacket(a8::UdpPacket* pkt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
ikcpcb* kcp_ = nullptr;
|
||||
long long remote_key_ = 0;
|
||||
sockaddr_in remote_addr_ = {};
|
||||
};
|
||||
|
||||
static void GSUdpListeneron_error(a8::UdpListener*, int errorid)
|
||||
@ -145,6 +158,18 @@ static void GSUdpListeneron_error(a8::UdpListener*, int errorid)
|
||||
|
||||
static void GSUdpListeneron_recv_packet(a8::UdpListener*, a8::UdpPacket* pkt)
|
||||
{
|
||||
std::shared_ptr<KcpSession> session;
|
||||
GCListener::Instance()->kcp_session_mutex_->lock();
|
||||
auto itr = GCListener::Instance()->kcp_session_addr_hash_.find(pkt->GetRemoteKey());
|
||||
if (itr == GCListener::Instance()->kcp_session_addr_hash_.end()) {
|
||||
session = std::make_shared<KcpSession>();
|
||||
GCListener::Instance()->kcp_session_addr_hash_[pkt->GetRemoteKey()] = session;
|
||||
session->Init(pkt);
|
||||
} else {
|
||||
session = itr->second;
|
||||
}
|
||||
GCListener::Instance()->kcp_session_mutex_->unlock();
|
||||
session->OnRecvPacket(pkt);
|
||||
}
|
||||
|
||||
void GCListener::Init()
|
||||
|
Loading…
x
Reference in New Issue
Block a user