mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-18 08:22:33 +02:00
Add explicit send quit command to connection
Make it more robust instead of waiting for a timeout
This commit is contained in:
parent
a6eb6b0660
commit
0669e2d1bf
@ -149,9 +149,11 @@ void ScreenPlayWallpaper::close()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_connection->close()) {
|
if (!m_connection->close()) {
|
||||||
m_isExiting = true;
|
qCritical() << "Cannot close wallpaper!";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
m_isExiting = true;
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
\brief Prints the exit code if != 0.
|
\brief Prints the exit code if != 0.
|
||||||
|
@ -113,6 +113,10 @@ bool ScreenPlay::SDKConnection::close()
|
|||||||
qWarning() << "Cannot close invalid socket.";
|
qWarning() << "Cannot close invalid socket.";
|
||||||
return false;
|
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();
|
qInfo() << "Close " << m_type << m_appID << m_socket->state();
|
||||||
m_socket->disconnectFromServer();
|
m_socket->disconnectFromServer();
|
||||||
|
@ -32,6 +32,9 @@ void ScreenPlaySDK::start()
|
|||||||
connect(&m_socket, &QLocalSocket::connected, this, &ScreenPlaySDK::connected);
|
connect(&m_socket, &QLocalSocket::connected, this, &ScreenPlaySDK::connected);
|
||||||
connect(&m_socket, &QLocalSocket::disconnected, this, &ScreenPlaySDK::disconnected);
|
connect(&m_socket, &QLocalSocket::disconnected, this, &ScreenPlaySDK::disconnected);
|
||||||
connect(&m_socket, &QLocalSocket::readyRead, this, &ScreenPlaySDK::readyRead);
|
connect(&m_socket, &QLocalSocket::readyRead, this, &ScreenPlaySDK::readyRead);
|
||||||
|
connect(&m_socket, &QLocalSocket::errorOccurred, this, [this](){
|
||||||
|
emit disconnected();
|
||||||
|
});
|
||||||
|
|
||||||
m_socket.connectToServer("ScreenPlay");
|
m_socket.connectToServer("ScreenPlay");
|
||||||
if (!m_socket.waitForConnected(1000)){
|
if (!m_socket.waitForConnected(1000)){
|
||||||
|
Loading…
Reference in New Issue
Block a user