From d0c0cabdcabaa20006d493f479af0dd307104c30 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 23 Apr 2023 19:10:28 +0800 Subject: [PATCH] 1 --- server/wsproxy/kcpsession.cc | 5 ----- server/wsproxy/kcpsession.h | 17 +++++++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/server/wsproxy/kcpsession.cc b/server/wsproxy/kcpsession.cc index 2549253..03056a1 100644 --- a/server/wsproxy/kcpsession.cc +++ b/server/wsproxy/kcpsession.cc @@ -43,16 +43,11 @@ void KcpSession::Init(int socket_handle) kcp_->rx_minrto = 10; kcp_->fastresend = 1; kcp_->output = UdpOutput; - recv_buff_ = (char *)malloc(max_packet_len_ + 1); init_tick_ = a8::XGetTickCount(); } void KcpSession::UnInit() { - if (recv_buff_) { - free(recv_buff_); - recv_buff_ = nullptr; - } if (kcp_) { ikcp_release(kcp_); kcp_ = nullptr; diff --git a/server/wsproxy/kcpsession.h b/server/wsproxy/kcpsession.h index 9c672cb..6f72d3e 100644 --- a/server/wsproxy/kcpsession.h +++ b/server/wsproxy/kcpsession.h @@ -15,23 +15,24 @@ public: void UnInit(); void Update(long long tick); - void SendClientMsg(char* buf, int buf_len); - virtual void OnRecvPacket(a8::UdpPacket* pkt) override; const sockaddr_in& GetAddr() const { return remote_addr_; } - void UpdateInput(); int GetSocketHandle() { return socket_handle_; } long long GetSecretKey() { return secret_key_; } + void SendClientMsg(char* buf, int buf_len); + virtual void OnRecvPacket(a8::UdpPacket* pkt) override; + protected: virtual void DecodeUserPacket(char* buf, int& offset, unsigned int buflen) override; private: - long long init_tick_ = 0; + void UpdateInput(); + +private: + int socket_handle_ = 0; long long secret_key_ = 0; ikcpcb* kcp_ = nullptr; - int socket_handle_ = 0; + + long long init_tick_ = 0; sockaddr_in remote_addr_ = {}; - char* recv_buff_ = nullptr; - int recv_bufflen_ = 0; - int max_packet_len_ = 1024 * 64 *2; };