libhv
libhv copied to clipboard
tcp客户端断线重连, 如何屏蔽弹框?
tcp客户端, 使用 断线重连功能, 每次重连都会弹框出来, 如何把弹框取消, 改成 输出日志? 或者干脆不要弹框了
`#include "pch.h" #include "fun_TcpClient.h"
TcpClient g_ClientOBj; SERVER_FUNC g_ServerMsgFunc[Server_Msg::s2c_message_end];
std::vector
void fun_InitClient() { int connfd = g_ClientOBj.createsocket(18666, "127.0.0.1"); if (connfd < 0) { AfxMessageBox("[fun_InitClient] - 创建Socket失败"); return; }
/*--- 连接事件回调 ---*/
g_ClientOBj.onConnection = fun_OnConnectionHandler;
/*--- 消息接收回调 ---*/
g_ClientOBj.onMessage = fun_OnMessageHandler;
/*--- 断线重连 ---*/
// reconnect: 1,2,4,8,10,10,10...
reconn_setting_t reconn;
reconn_setting_init(&reconn);
reconn.min_delay = 1000;
reconn.max_delay = 10000;
reconn.delay_policy = 2;
g_ClientOBj.setReconnect(&reconn);
// 启动客户端
g_ClientOBj.start();
}`