From c33530ce1d69f78169ac27648a656979c6aae0d7 Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Wed, 8 Sep 2021 23:55:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Etcps=20swarm=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=9A=84lua=E4=BA=8B=E4=BB=B6=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protoDebuger/network_controller.cpp | 7 +++---- protoDebuger/network_controller.h | 3 ++- protoDebuger/tcp_swarm_libevent.cpp | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/protoDebuger/network_controller.cpp b/protoDebuger/network_controller.cpp index d07fb1c..7e1fea2 100644 --- a/protoDebuger/network_controller.cpp +++ b/protoDebuger/network_controller.cpp @@ -17,7 +17,6 @@ NetworkController::NetworkController(NetworkController::NetworkType type, { mType = type; if(_checkType(type) == TYPE_UNKOWN){ - } if(type == NetworkType::TYPE_TCP_CLIENT){ mTcp = new QTcpSocket(); @@ -178,11 +177,11 @@ void NetworkController::on_server_accept() QObject::connect(pClientConnection, SIGNAL(readyRead()), this, SLOT(on_ready_read())); QObject::connect(pClientConnection, SIGNAL(disconnected()), this, SLOT(on_disconect())); } - mTcp = pClientConnection; - mCnn = mTcp; + qDebug()<socketDescriptor(); +// mTcp = pClientConnection; +// mCnn = mTcp; mState = true; emit(on_connected()); - } } diff --git a/protoDebuger/network_controller.h b/protoDebuger/network_controller.h index 612854e..d2eee4d 100644 --- a/protoDebuger/network_controller.h +++ b/protoDebuger/network_controller.h @@ -8,6 +8,7 @@ #include #include #include +#include // this is not a thread-safe class,any interface invoked in multi-thread maybe will cause unkown falut class NetworkController : public QObject @@ -57,7 +58,7 @@ private: QTcpSocket *mTcp; QTcpServer *mTcpServer; QIODevice *mCnn; - + QMap m_clients; QThread mThread; bool mState; }; diff --git a/protoDebuger/tcp_swarm_libevent.cpp b/protoDebuger/tcp_swarm_libevent.cpp index e5eb0ca..e767c39 100644 --- a/protoDebuger/tcp_swarm_libevent.cpp +++ b/protoDebuger/tcp_swarm_libevent.cpp @@ -73,7 +73,6 @@ int TcpSwarmClientLibevent::addConection(evutil_socket_t fd,struct bufferevent* return 0; } - int TcpSwarmClientLibevent::removeConection(evutil_socket_t fd){ m_clients.erase(fd); return 0;