提交 49ae07bc 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

避免偶尔的失败

上级 1dbe5740
...@@ -5,15 +5,9 @@ ...@@ -5,15 +5,9 @@
#include "proxyobject.h" #include "proxyobject.h"
STMsgLogger::st_logger g_logger; STMsgLogger::st_logger g_logger;
QTextStream stream(stdout,QIODevice::WriteOnly);
void stMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) void stMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{ {
g_logger.MessageOutput(type,context,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[]) int main(int argc, char *argv[])
......
...@@ -16,19 +16,21 @@ ProxyObject::ProxyObject(QObject *parent) ...@@ -16,19 +16,21 @@ ProxyObject::ProxyObject(QObject *parent)
: QObject(parent) : QObject(parent)
, engine(new ZPNetwork::zp_net_Engine(2048,this)) , 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_Message, this, &ProxyObject::slot_Message ,Qt::QueuedConnection);
connect (engine, &zp_net_Engine::evt_SocketError, this, &ProxyObject::slot_SocketError ); connect (engine, &zp_net_Engine::evt_SocketError, this, &ProxyObject::slot_SocketError,Qt::QueuedConnection );
connect (engine, &zp_net_Engine::evt_NewClientConnected, this, &ProxyObject::slot_NewClientConnected ); connect (engine, &zp_net_Engine::evt_NewClientConnected, this, &ProxyObject::slot_NewClientConnected,Qt::QueuedConnection );
connect (engine, &zp_net_Engine::evt_ClientDisconnected, this, &ProxyObject::slot_ClientDisconnected ); 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 ); connect (engine, &zp_net_Engine::evt_Data_recieved, this, &ProxyObject::slot_Data_recieved ,Qt::QueuedConnection);
connect (engine, &zp_net_Engine::evt_Data_transferred, this, &ProxyObject::slot_Data_transferred );
initEngine(); initEngine();
m_nTimerRefresh = startTimer(1000); m_nTimerRefresh = startTimer(1000);
} }
void ProxyObject::slot_Message(QObject * pSource,QString message ) void ProxyObject::slot_Message(QObject * pSource,QString message )
{ {
QString msg = message + tr(",Source=%1").arg((quint64)pSource); QString msg = message + tr(",Source=%1").arg((quint64)pSource);
qDebug()<<msg; QTextStream stout(stdout,QIODevice::WriteOnly);
QDateTime dtm = QDateTime::currentDateTime();
QString msgOut = dtm.toString("yyyy-MM-dd HH:mm:ss.zzz") + " " + msg;
stout<<msgOut<<"\n";
} }
void ProxyObject::initEngine() void ProxyObject::initEngine()
{ {
...@@ -126,14 +128,14 @@ void ProxyObject::slot_NewClientConnected(QObject * clientHandle) ...@@ -126,14 +128,14 @@ void ProxyObject::slot_NewClientConnected(QObject * clientHandle)
else else
{ {
qWarning()<<"Incomming Out connection has no pending local peer. Port="<<nLocalPort; qWarning()<<"Incomming Out connection has no pending local peer. Port="<<nLocalPort;
engine->KickClients(clientHandle); //engine->KickClients(clientHandle);
} }
} }
else else
{ {
qWarning()<<"Incomming Out connection "<<pn<<"has no local Port"; qWarning()<<"Incomming Out connection "<<pn<<"has no local Port";
engine->KickClients(clientHandle); //engine->KickClients(clientHandle);
} }
} }
else else
...@@ -176,12 +178,6 @@ void ProxyObject::slot_Data_recieved(QObject * clientHandle,QByteArray datablo ...@@ -176,12 +178,6 @@ void ProxyObject::slot_Data_recieved(QObject * clientHandle,QByteArray datablo
penging_data[clientHandle].push_back(datablock); 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) void ProxyObject::timerEvent(QTimerEvent *event)
{ {
if (event->timerId()==m_nTimerRefresh) if (event->timerId()==m_nTimerRefresh)
......
...@@ -38,8 +38,6 @@ public slots: ...@@ -38,8 +38,6 @@ public slots:
void slot_ClientDisconnected(QObject * /*clientHandle*/); void slot_ClientDisconnected(QObject * /*clientHandle*/);
//some data arrival //some data arrival
void slot_Data_recieved(QObject * /*clientHandle*/,QByteArray /*datablock*/ ); 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 #endif // PROXYOBJECT_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册