1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-14 22:42:34 +02:00

Add explicit send quit command to connection

Make it more robust instead of waiting for a timeout
This commit is contained in:
Elias Steurer 2023-01-22 16:27:59 +01:00
parent a6eb6b0660
commit 0669e2d1bf
3 changed files with 11 additions and 2 deletions

View File

@ -149,9 +149,11 @@ void ScreenPlayWallpaper::close()
return;
}
if (m_connection->close()) {
m_isExiting = true;
if (!m_connection->close()) {
qCritical() << "Cannot close wallpaper!";
return;
}
m_isExiting = true;
}
/*!
\brief Prints the exit code if != 0.

View File

@ -113,6 +113,10 @@ bool ScreenPlay::SDKConnection::close()
qWarning() << "Cannot close invalid socket.";
return false;
}
QJsonObject obj;
obj.insert("command", "quit");
m_socket->write(QByteArray(QJsonDocument(obj).toJson(QJsonDocument::Compact)));
m_socket->flush();
qInfo() << "Close " << m_type << m_appID << m_socket->state();
m_socket->disconnectFromServer();

View File

@ -32,6 +32,9 @@ void ScreenPlaySDK::start()
connect(&m_socket, &QLocalSocket::connected, this, &ScreenPlaySDK::connected);
connect(&m_socket, &QLocalSocket::disconnected, this, &ScreenPlaySDK::disconnected);
connect(&m_socket, &QLocalSocket::readyRead, this, &ScreenPlaySDK::readyRead);
connect(&m_socket, &QLocalSocket::errorOccurred, this, [this](){
emit disconnected();
});
m_socket.connectToServer("ScreenPlay");
if (!m_socket.waitForConnected(1000)){