diff options
Diffstat (limited to 'client/Client.cpp')
-rw-r--r-- | client/Client.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/client/Client.cpp b/client/Client.cpp index e50be5e..61e51e4 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -18,28 +18,32 @@ Client::~Client() delete timer; } -void Client::ClientEcho() -{ - - connect(timer, SIGNAL(timeout()),this,SLOT(timeFunction())); // connect timer to time every minute - - // connect to readyread to receive data; - connect(socket,&QTcpSocket::readyRead, [&]() { - QTextStream T(socket); - QString text = T.readAll(); // reads all data - Handlemsg.ParseToSQL(Handlemsg.ParseMessage(text, (totalRecords-'0'))); +void Client::ClientEcho() { + static unsigned int lineCounter = 0; + connect(timer, SIGNAL(timeout()),this,SLOT(timeFunction())); // connect timer to time every minute + // connect to readyread to receive data; + connect(socket,&QTcpSocket::readyRead, [&]() { + QTextStream T(socket); + QString text = T.readAll(); // reads all data + lineCounter++; + if (lineCounter <= 2) return; + Handlemsg.ParseToSQL(text); + }); - }); + connect(socket, &QTcpSocket::disconnected, [&]() { + socket->disconnectFromHost(); + lineCounter = 0; + }); - timer->start(1000); + timer->start(1000); } void Client::timeFunction() { if((QTime::currentTime().second() % WS_CLIENT_STATION_POLL_INTERVAL) != 0) return; this->missingRecords(); - totalRecords = WS_MAX(1, _missingRecords); + totalRecords = WS_MIN(WS_MAX(1, _missingRecords), 50); char* msg = NULL; asprintf(&msg, "last-records %x %x\n", totalRecords, offsetRecords); |