minor patch

This commit is contained in:
Dorian Zedler 2020-04-06 22:22:26 +02:00
parent a9e9e4fd0f
commit 02b759b406
Signed by: dorian
GPG key ID: 989DE36109AFA354

View file

@ -22,7 +22,7 @@ ScStwClient::ScStwClient() : QObject(nullptr)
connect(this->socket, &QAbstractSocket::stateChanged,
this, &ScStwClient::handleSocketStateChange);
connect(this->socket, &QTcpSocket::readyRead,
connect(this->socket, &QAbstractSocket::readyRead,
this, &ScStwClient::handleReadyRead);
@ -109,7 +109,7 @@ QVariantMap ScStwClient::sendCommand(int header, QJsonValue data, int timeout) {
if(this->state != CONNECTED)
return {{"status", ScStw::NotConnectedError}, {"data", "not connected"}};
return this->sendCommand(header, data, timeout, false);
return this->sendCommand(header, data, timeout, true);
}
QVariantMap ScStwClient::sendCommand(int header, QJsonValue data, int timeout, bool useTerminationKeys) {
@ -142,12 +142,10 @@ QVariantMap ScStwClient::sendCommand(int header, QJsonValue data, int timeout, b
timer->start(timeout);
//write data
if(useTerminationKeys) {
socket->write("<message>" + jsonRequest.toLatin1() + "</message>");
}
else {
socket->write(jsonRequest.toLatin1());
}
if(useTerminationKeys)
socket->write(ScStw::SOCKET_MESSAGE_START_KEY + jsonRequest.toUtf8() + ScStw::SOCKET_MESSAGE_END_KEY);
else
socket->write(jsonRequest.toUtf8());
//wait for an answer to finish (programm gets stuck in here)
loop->exec();
@ -172,7 +170,7 @@ QVariantMap ScStwClient::sendCommand(int header, QJsonValue data, int timeout, b
if(!replyFound) {
// some internal error occured
return {{"status", 900}, {"data", ""}};
return {{"status", ScStw::Error}, {"data", ""}};
}
if(timer->remainingTime() == -1){