新增tcps swarm模式的lua事件绑定

master
zcy 2021-09-08 23:55:27 +08:00
parent 6e80dda35b
commit c33530ce1d
3 changed files with 5 additions and 6 deletions

View File

@ -17,7 +17,6 @@ NetworkController::NetworkController(NetworkController::NetworkType type,
{ {
mType = type; mType = type;
if(_checkType(type) == TYPE_UNKOWN){ if(_checkType(type) == TYPE_UNKOWN){
} }
if(type == NetworkType::TYPE_TCP_CLIENT){ if(type == NetworkType::TYPE_TCP_CLIENT){
mTcp = new QTcpSocket(); 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(readyRead()), this, SLOT(on_ready_read()));
QObject::connect(pClientConnection, SIGNAL(disconnected()), this, SLOT(on_disconect())); QObject::connect(pClientConnection, SIGNAL(disconnected()), this, SLOT(on_disconect()));
} }
mTcp = pClientConnection; qDebug()<<pClientConnection->socketDescriptor();
mCnn = mTcp; // mTcp = pClientConnection;
// mCnn = mTcp;
mState = true; mState = true;
emit(on_connected()); emit(on_connected());
} }
} }

View File

@ -8,6 +8,7 @@
#include <QThread> #include <QThread>
#include <QTcpServer> #include <QTcpServer>
#include <QNetworkDatagram> #include <QNetworkDatagram>
#include <QMap>
// this is not a thread-safe class,any interface invoked in multi-thread maybe will cause unkown falut // this is not a thread-safe class,any interface invoked in multi-thread maybe will cause unkown falut
class NetworkController : public QObject class NetworkController : public QObject
@ -57,7 +58,7 @@ private:
QTcpSocket *mTcp; QTcpSocket *mTcp;
QTcpServer *mTcpServer; QTcpServer *mTcpServer;
QIODevice *mCnn; QIODevice *mCnn;
QMap<qintptr,QTcpSocket *> m_clients;
QThread mThread; QThread mThread;
bool mState; bool mState;
}; };

View File

@ -73,7 +73,6 @@ int TcpSwarmClientLibevent::addConection(evutil_socket_t fd,struct bufferevent*
return 0; return 0;
} }
int TcpSwarmClientLibevent::removeConection(evutil_socket_t fd){ int TcpSwarmClientLibevent::removeConection(evutil_socket_t fd){
m_clients.erase(fd); m_clients.erase(fd);
return 0; return 0;