diff --git a/ScreenPlay/src/sdkconnector.h b/ScreenPlay/src/sdkconnector.h index 157fafd9..2f7b81fd 100644 --- a/ScreenPlay/src/sdkconnector.h +++ b/ScreenPlay/src/sdkconnector.h @@ -188,6 +188,16 @@ public slots: void close() { + + qInfo() << "Close " << m_type; + + QJsonObject obj; + obj.insert("command", QJsonValue("quit")); + QByteArray command = QJsonDocument(obj).toJson(); + + m_socket->write(command); + m_socket->waitForBytesWritten(); + if (m_socket->state() == QLocalSocket::ConnectedState) { m_socket->disconnectFromServer(); m_socket->close(); diff --git a/ScreenPlaySDK/screenplaysdk.cpp b/ScreenPlaySDK/screenplaysdk.cpp index d007b0de..08b25451 100644 --- a/ScreenPlaySDK/screenplaysdk.cpp +++ b/ScreenPlaySDK/screenplaysdk.cpp @@ -77,6 +77,15 @@ void ScreenPlaySDK::readyRead() return; } QJsonObject ob = doc.object(); + + if(ob.size() == 1){ + if(ob.contains("command")){ + if(ob.value("command") == "quit"){ + emit sdkDisconnected(); + return; + } + } + } QJsonObject::iterator iterator; for (iterator = ob.begin(); iterator != ob.end(); iterator++) { emit incommingMessage(iterator.key(), ob.value(iterator.key()).toString());