@@ -10,6 +10,7 @@ TcpSocket::TcpSocket(qintptr socketDescriptor, QObject *parent) : //构造函数
1010 connect (this ,&TcpSocket::readyRead,this ,&TcpSocket::readData);
1111 dis = connect (this ,&TcpSocket::disconnected,
1212 [&](){
13+ qDebug () << " disconnect" ;
1314 emit sockDisConnect (socketID,this ->peerAddress ().toString (),this ->peerPort (),QThread::currentThread ());// 发送断开连接的用户信息
1415 this ->deleteLater ();
1516 });
@@ -47,13 +48,14 @@ void TcpSocket::disConTcp(int i)
4748
4849void TcpSocket::readData ()
4950{
50- datas.append (this ->readAll ());
51- // auto data = handleData(this->readAll(),this->peerAddress().toString(),this->peerPort());
52- // this->write(data);
53- if (!watcher.isRunning ())// 放到异步线程中处理。
54- {
55- watcher.setFuture (QtConcurrent::run (this ,&TcpSocket::handleData,datas.dequeue (),this ->peerAddress ().toString (),this ->peerPort ()));
56- }
51+ // datas.append(this->readAll());
52+ auto data = handleData (this ->readAll (),this ->peerAddress ().toString (),this ->peerPort ());
53+ qDebug () << data;
54+ this ->write (data);
55+ // if (!watcher.isRunning())//放到异步线程中处理。
56+ // {
57+ // watcher.setFuture(QtConcurrent::run(this,&TcpSocket::handleData,datas.dequeue(),this->peerAddress().toString(),this->peerPort()));
58+ // }
5759}
5860
5961QByteArray TcpSocket::handleData (QByteArray data, const QString &ip, qint16 port)
0 commit comments