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