From 49ae07bc1f63331a382febe3473f7dfc23e5f3c5 Mon Sep 17 00:00:00 2001 From: goldenhawking Date: Sat, 3 Dec 2016 09:17:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=81=B6=E5=B0=94=E7=9A=84?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 6 ------ proxyobject.cpp | 28 ++++++++++++---------------- proxyobject.h | 2 -- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/main.cpp b/main.cpp index 681e768..aadfbbc 100644 --- a/main.cpp +++ b/main.cpp @@ -5,15 +5,9 @@ #include "proxyobject.h" STMsgLogger::st_logger g_logger; -QTextStream stream(stdout,QIODevice::WriteOnly); void stMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { g_logger.MessageOutput(type,context,msg); - - QDateTime dtm = QDateTime::currentDateTime(); - QString msgOut = dtm.toString("yyyy-MM-dd HH:mm:ss.zzz") + ">" + msg; - stream << msgOut <<"\n"; - stream.flush(); } int main(int argc, char *argv[]) diff --git a/proxyobject.cpp b/proxyobject.cpp index 239ea83..5d64c2c 100644 --- a/proxyobject.cpp +++ b/proxyobject.cpp @@ -16,19 +16,21 @@ ProxyObject::ProxyObject(QObject *parent) : QObject(parent) , engine(new ZPNetwork::zp_net_Engine(2048,this)) { - connect (engine, &zp_net_Engine::evt_Message, this, &ProxyObject::slot_Message ); - connect (engine, &zp_net_Engine::evt_SocketError, this, &ProxyObject::slot_SocketError ); - connect (engine, &zp_net_Engine::evt_NewClientConnected, this, &ProxyObject::slot_NewClientConnected ); - connect (engine, &zp_net_Engine::evt_ClientDisconnected, this, &ProxyObject::slot_ClientDisconnected ); - connect (engine, &zp_net_Engine::evt_Data_recieved, this, &ProxyObject::slot_Data_recieved ); - connect (engine, &zp_net_Engine::evt_Data_transferred, this, &ProxyObject::slot_Data_transferred ); + connect (engine, &zp_net_Engine::evt_Message, this, &ProxyObject::slot_Message ,Qt::QueuedConnection); + connect (engine, &zp_net_Engine::evt_SocketError, this, &ProxyObject::slot_SocketError,Qt::QueuedConnection ); + connect (engine, &zp_net_Engine::evt_NewClientConnected, this, &ProxyObject::slot_NewClientConnected,Qt::QueuedConnection ); + connect (engine, &zp_net_Engine::evt_ClientDisconnected, this, &ProxyObject::slot_ClientDisconnected ,Qt::QueuedConnection); + connect (engine, &zp_net_Engine::evt_Data_recieved, this, &ProxyObject::slot_Data_recieved ,Qt::QueuedConnection); initEngine(); m_nTimerRefresh = startTimer(1000); } void ProxyObject::slot_Message(QObject * pSource,QString message ) { QString msg = message + tr(",Source=%1").arg((quint64)pSource); - qDebug()<KickClients(clientHandle); + //engine->KickClients(clientHandle); } } else @@ -176,18 +178,12 @@ void ProxyObject::slot_Data_recieved(QObject * clientHandle,QByteArray datablo penging_data[clientHandle].push_back(datablock); } -//a block of data has been successfuly sent -void ProxyObject::slot_Data_transferred(QObject * clientHandle,qint64 bytes_sent) -{ - -} - void ProxyObject::timerEvent(QTimerEvent *event) { if (event->timerId()==m_nTimerRefresh) { static int counter = 0; - fprintf (stdout,"Send %.2lf MB(%.2lfkbps) Rev %.2lf MB (%.2lfkbps) \r", + fprintf (stdout,"Send %.2lf MB(%.2lfkbps) Rev %.2lf MB (%.2lfkbps) \r", g_bytesRecieved/1024.0/1024.0, g_secRecieved /1024.0*8, g_bytesSent/1024.0/1024.0, diff --git a/proxyobject.h b/proxyobject.h index 1eebdc8..060b828 100644 --- a/proxyobject.h +++ b/proxyobject.h @@ -38,8 +38,6 @@ public slots: void slot_ClientDisconnected(QObject * /*clientHandle*/); //some data arrival void slot_Data_recieved(QObject * /*clientHandle*/,QByteArray /*datablock*/ ); - //a block of data has been successfuly sent - void slot_Data_transferred(QObject * /*clientHandle*/,qint64 /*bytes sent*/); }; #endif // PROXYOBJECT_H -- GitLab