1
This commit is contained in:
parent
ba1dc5f3c1
commit
06d1314f29
@ -17,15 +17,14 @@ static int UdpOutput(const char *buf, int len, ikcpcb *kcp, void *user)
|
||||
pkt->buf = buf;
|
||||
pkt->buf_len = len;
|
||||
pkt->remote_addr = session->GetAddr();
|
||||
#if 0
|
||||
session->GetUdpListener()->SendUdpPacket(pkt);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void KcpSession::Init(a8::UdpListener* udp_listener, int socket_handle, a8::UdpPacket* pkt)
|
||||
void KcpSession::Init(int socket_handle)
|
||||
{
|
||||
udp_listener_ = udp_listener;
|
||||
remote_key_ = pkt->GetRemoteKey();
|
||||
remote_addr_ = pkt->remote_addr;
|
||||
socket_handle_ = socket_handle;
|
||||
kcp_ = ikcp_create(socket_handle_, (void*)this);
|
||||
ikcp_wndsize(kcp_, 128, 128);
|
||||
|
@ -9,14 +9,13 @@ class KcpSession
|
||||
{
|
||||
public:
|
||||
|
||||
void Init(a8::UdpListener* udp_listener, int socket_handle, a8::UdpPacket* pkt);
|
||||
void Init(int socket_handle);
|
||||
void UnInit();
|
||||
void Update(long long tick);
|
||||
|
||||
void SendClientMsg(char* buf, int buf_len);
|
||||
void OnRecvPacket(a8::UdpPacket* pkt);
|
||||
const sockaddr_in& GetAddr() const { return remote_addr_; }
|
||||
a8::UdpListener* GetUdpListener() { return udp_listener_; }
|
||||
void UpdateInput();
|
||||
int GetSocketHandle() { return socket_handle_; }
|
||||
long long GetSecretKey() { return secret_key_; }
|
||||
@ -27,10 +26,8 @@ public:
|
||||
private:
|
||||
long long init_tick_ = 0;
|
||||
long long secret_key_ = 0;
|
||||
a8::UdpListener* udp_listener_ = nullptr;
|
||||
ikcpcb* kcp_ = nullptr;
|
||||
int socket_handle_ = 0;
|
||||
long long remote_key_ = 0;
|
||||
sockaddr_in remote_addr_ = {};
|
||||
char* recv_buff_ = nullptr;
|
||||
int recv_bufflen_ = 0;
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <f8/netmsghandler.h>
|
||||
|
||||
#include "longsession.h"
|
||||
#include "kcpsession.h"
|
||||
|
||||
@ -9,6 +11,7 @@
|
||||
void LongSession::Init(f8::MsgHdr& hdr, const ss::SS_CMKcpHandshake& msg)
|
||||
{
|
||||
kcp_session_ = std::make_shared<KcpSession>();
|
||||
kcp_session_->Init(hdr.socket_handle);
|
||||
}
|
||||
|
||||
void LongSession::UnInit()
|
||||
|
Loading…
x
Reference in New Issue
Block a user