From ff47a114b97a39dbd03b096346b3c3d9acf29e50 Mon Sep 17 00:00:00 2001 From: zct <290198252@qq.com> Date: Tue, 6 Jul 2021 20:55:34 +0800 Subject: [PATCH] no message --- .gitignore | 3 +++ server/tcp_client.cpp | 12 ++++-------- server/tcp_client.h | 3 +-- server/tcp_server_libevent.h | 5 +++-- server/tcp_swarm_libevent.h | 3 +-- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 259148f..21fd069 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,6 @@ *.exe *.out *.app +server/build/* +server/third/* +.vscode/* diff --git a/server/tcp_client.cpp b/server/tcp_client.cpp index 3e7e204..e6d5b8f 100644 --- a/server/tcp_client.cpp +++ b/server/tcp_client.cpp @@ -82,23 +82,20 @@ void conn_eventcb(struct bufferevent *bev, short events, void *user_data) { TcpClientLibevent *p; p = (TcpClientLibevent *)user_data; - if (events & BEV_EVENT_EOF) - { + if (events & BEV_EVENT_EOF) { if (nullptr != p->mObserver) p->mObserver->OnDisConnected(); if (p != nullptr) p->mStatus = TcpClientLibevent::UNCONNECTED; printf("Connection closed\n"); } - else if (events & BEV_EVENT_ERROR) - { + else if (events & BEV_EVENT_ERROR) { printf("Got an error on the connection: %s\n", strerror(errno)); if (nullptr != p->mObserver) p->mObserver->OnDisConnected(); p->mStatus = TcpClientLibevent::FAIL; } - else if (events & BEV_EVENT_CONNECTED) - { + else if (events & BEV_EVENT_CONNECTED) { printf("Connect succeed\n"); //客户端链接成功后,给服务器发送第一条消息 if (nullptr != p->mObserver) @@ -163,8 +160,7 @@ int TcpClientLibevent::ConnectServer() { bufferevent_setcb(bev, conn_readcb, conn_writecb, conn_eventcb, this); int flag = bufferevent_socket_connect(bev, (struct sockaddr *)&mSrv, sizeof(mSrv)); bufferevent_enable(bev, EV_READ | EV_WRITE); - if (-1 == flag) - { + if (-1 == flag) { this->mStatus = TcpClientLibevent::FAIL; bufferevent_free(bev); bev = nullptr; diff --git a/server/tcp_client.h b/server/tcp_client.h index 748dbee..e5397e6 100644 --- a/server/tcp_client.h +++ b/server/tcp_client.h @@ -22,9 +22,8 @@ extern "C"{ #include "event2/util.h" #include "event2/event.h" #include "event2/thread.h" - #include }; - +#include #include // #include "PackageReceiver.h" #include diff --git a/server/tcp_server_libevent.h b/server/tcp_server_libevent.h index 21b89ee..a1b797d 100644 --- a/server/tcp_server_libevent.h +++ b/server/tcp_server_libevent.h @@ -2,7 +2,7 @@ /* * @Author: your name * @Date: 2021-06-30 16:23:10 - * @LastEditTime: 2021-07-04 13:37:58 + * @LastEditTime: 2021-07-06 20:50:25 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \server\tcp_server_libevent.h @@ -28,8 +28,9 @@ extern "C"{ #include "event2/util.h" #include "event2/event.h" #include "event2/thread.h" + #include }; -#include + #include #include #include diff --git a/server/tcp_swarm_libevent.h b/server/tcp_swarm_libevent.h index d68d3b6..17b9a73 100644 --- a/server/tcp_swarm_libevent.h +++ b/server/tcp_swarm_libevent.h @@ -1,7 +1,7 @@ /* * @Author: your name * @Date: 2021-07-04 16:39:42 - * @LastEditTime: 2021-07-05 00:19:40 + * @LastEditTime: 2021-07-06 20:21:10 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \server\tcp_swarm_libevent.h @@ -66,5 +66,4 @@ private: uint32_t m_count; int removeConection(evutil_socket_t fd); }; - #endif //GENERAL_TCPCLIENT_H