|
|
|
@ -45,8 +45,18 @@ Connection::Connection(QTcpSocket *socket, IRequestHandler *requestHandler, QObj
@@ -45,8 +45,18 @@ Connection::Connection(QTcpSocket *socket, IRequestHandler *requestHandler, QObj
|
|
|
|
|
, m_requestHandler(requestHandler) |
|
|
|
|
{ |
|
|
|
|
m_socket->setParent(this); |
|
|
|
|
|
|
|
|
|
// reset timer when there are activity
|
|
|
|
|
m_idleTimer.start(); |
|
|
|
|
connect(m_socket, &QIODevice::readyRead, this, [this]() |
|
|
|
|
{ |
|
|
|
|
m_idleTimer.start(); |
|
|
|
|
read(); |
|
|
|
|
}); |
|
|
|
|
connect(m_socket, &QIODevice::bytesWritten, this, [this]() |
|
|
|
|
{ |
|
|
|
|
m_idleTimer.start(); |
|
|
|
|
connect(m_socket, &QTcpSocket::readyRead, this, &Connection::read); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Connection::~Connection() |
|
|
|
@ -56,7 +66,6 @@ Connection::~Connection()
@@ -56,7 +66,6 @@ Connection::~Connection()
|
|
|
|
|
|
|
|
|
|
void Connection::read() |
|
|
|
|
{ |
|
|
|
|
m_idleTimer.restart(); |
|
|
|
|
m_receivedData.append(m_socket->readAll()); |
|
|
|
|
|
|
|
|
|
while (!m_receivedData.isEmpty()) |
|
|
|
|