Skip to content

Commit

Permalink
fix code shell.
Browse files Browse the repository at this point in the history
  • Loading branch information
freeeyes committed Jun 28, 2024
1 parent cc63d36 commit 65ed4b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions PSS_ASIO/UdpSession/KcpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ uint32 CKcpServer::add_udp_endpoint(const udp::endpoint& recv_endpoint, size_t l
udp_endpoint_2_id_list_[recv_endpoint] = connect_id;
udp_id_2_endpoint_list_[connect_id] = session_info;

kcp_output_func kcp_output_func_ptr = kcp_udpOutPut;
kcp_output_func output_func = kcp_udpOutPut;

//创建KCP
session_info->init_kcp(connect_id, max_recv_size_, max_send_size_, kcp_output_func_ptr, this);
session_info->init_kcp(connect_id, max_recv_size_, max_send_size_, output_func, this);

//刷新一下时间
ikcp_update(session_info->kcpcb_, iclock());
Expand Down
8 changes: 7 additions & 1 deletion PSS_ASIO/UdpSession/KcpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class CKcp_send_info

using kcp_output_func = std::function<int(const char* buf, int len, ikcpcb* kcp, void* user)>;

using kcp_output_func_ptr = int(*)(const char* buf, int len, ikcpcb* kcp, void* user);

class CKcp_Session_Info
{
public:
Expand All @@ -69,7 +71,11 @@ class CKcp_Session_Info
else
{
//绑定回调函数
kcpcb_->output = output_func.target<int(const char*, int, ikcpcb*, void*)>();
auto ptr = output_func.target<kcp_output_func_ptr>();
if (ptr)
{
kcpcb_->output = *ptr;
}

ikcp_nodelay(kcpcb_, 0, 10, 0, 0);
ikcp_wndsize(kcpcb_, max_send_size, max_recv_size);
Expand Down

0 comments on commit 65ed4b2

Please sign in to comment.