1
This commit is contained in:
parent
8e251100d2
commit
d0c0cabdca
@ -43,16 +43,11 @@ void KcpSession::Init(int socket_handle)
|
|||||||
kcp_->rx_minrto = 10;
|
kcp_->rx_minrto = 10;
|
||||||
kcp_->fastresend = 1;
|
kcp_->fastresend = 1;
|
||||||
kcp_->output = UdpOutput;
|
kcp_->output = UdpOutput;
|
||||||
recv_buff_ = (char *)malloc(max_packet_len_ + 1);
|
|
||||||
init_tick_ = a8::XGetTickCount();
|
init_tick_ = a8::XGetTickCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KcpSession::UnInit()
|
void KcpSession::UnInit()
|
||||||
{
|
{
|
||||||
if (recv_buff_) {
|
|
||||||
free(recv_buff_);
|
|
||||||
recv_buff_ = nullptr;
|
|
||||||
}
|
|
||||||
if (kcp_) {
|
if (kcp_) {
|
||||||
ikcp_release(kcp_);
|
ikcp_release(kcp_);
|
||||||
kcp_ = nullptr;
|
kcp_ = nullptr;
|
||||||
|
@ -15,23 +15,24 @@ public:
|
|||||||
void UnInit();
|
void UnInit();
|
||||||
void Update(long long tick);
|
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_; }
|
const sockaddr_in& GetAddr() const { return remote_addr_; }
|
||||||
void UpdateInput();
|
|
||||||
int GetSocketHandle() { return socket_handle_; }
|
int GetSocketHandle() { return socket_handle_; }
|
||||||
long long GetSecretKey() { return secret_key_; }
|
long long GetSecretKey() { return secret_key_; }
|
||||||
|
|
||||||
|
void SendClientMsg(char* buf, int buf_len);
|
||||||
|
virtual void OnRecvPacket(a8::UdpPacket* pkt) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DecodeUserPacket(char* buf, int& offset, unsigned int buflen) override;
|
virtual void DecodeUserPacket(char* buf, int& offset, unsigned int buflen) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long init_tick_ = 0;
|
void UpdateInput();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int socket_handle_ = 0;
|
||||||
long long secret_key_ = 0;
|
long long secret_key_ = 0;
|
||||||
ikcpcb* kcp_ = nullptr;
|
ikcpcb* kcp_ = nullptr;
|
||||||
int socket_handle_ = 0;
|
|
||||||
|
long long init_tick_ = 0;
|
||||||
sockaddr_in remote_addr_ = {};
|
sockaddr_in remote_addr_ = {};
|
||||||
char* recv_buff_ = nullptr;
|
|
||||||
int recv_bufflen_ = 0;
|
|
||||||
int max_packet_len_ = 1024 * 64 *2;
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user