fix packet fragmentation on TCP layer

pull/135/head
Michael Zanetti 2017-09-16 18:46:28 +02:00
parent 6c28e51c1e
commit 69bf56af09
3 changed files with 12 additions and 2 deletions

1
.gitignore vendored
View File

@ -32,6 +32,7 @@ tests/auto/devices/testdevices
tests/auto/events/testevents
tests/auto/jsonrpc/testjsonrpc
tests/auto/logging/testlogging
tests/auto/logging/testloggingdirect
tests/auto/plugins/testactions
tests/auto/restdeviceclasses/restdeviceclasses
tests/auto/restdevices/restdevices

View File

@ -221,8 +221,16 @@ void SslServer::onClientDisconnected()
void SslServer::onSocketReadyRead()
{
QSslSocket *socket = static_cast<QSslSocket*>(sender());
QByteArray data = socket->readAll();
emit dataAvailable(socket, data);
m_receiveBuffer.append(socket->readAll());
int splitIndex = m_receiveBuffer.indexOf("}\n{");
while (splitIndex > -1) {
emit dataAvailable(socket, m_receiveBuffer.left(splitIndex + 1));
m_receiveBuffer = m_receiveBuffer.right(m_receiveBuffer.length() - splitIndex - 2);
splitIndex = m_receiveBuffer.indexOf("}\n{");
}
if (m_receiveBuffer.endsWith("}\n")) {
emit dataAvailable(socket, m_receiveBuffer);
}
}
}

View File

@ -65,6 +65,7 @@ private slots:
private:
bool m_sslEnabled = false;
QSslConfiguration m_config;
QByteArray m_receiveBuffer;
};
class TcpServer : public TransportInterface