新增tcps swarm模式的lua事件绑定
parent
6e80dda35b
commit
c33530ce1d
|
@ -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());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue