Skip to content

Commit

Permalink
fix std::function C++11 code smell.
Browse files Browse the repository at this point in the history
  • Loading branch information
freeeyes committed Jun 28, 2024
1 parent 652bdbb commit a37729f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion PSS_ASIO/UdpSession/KcpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +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
session_info->init_kcp(connect_id, max_recv_size_, max_send_size_, kcp_udpOutPut, this);
session_info->init_kcp(connect_id, max_recv_size_, max_send_size_, kcp_output_func_ptr, this);

//刷新一下时间
ikcp_update(session_info->kcpcb_, iclock());
Expand Down
4 changes: 2 additions & 2 deletions PSS_ASIO/UdpSession/KcpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CKcp_send_info
udp::endpoint send_endpoint;
};

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

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

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

0 comments on commit a37729f

Please sign in to comment.