minor patch
This commit is contained in:
parent
a9e9e4fd0f
commit
02b759b406
1 changed files with 7 additions and 9 deletions
|
@ -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){
|
||||
|
|
Reference in a new issue