1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-06 19:12:30 +01:00

Add another check if main application is still running

The timeout of pipes is quite high so we need to ping them regularly
This commit is contained in:
Elias Steurer 2020-08-14 11:28:58 +02:00
parent 41a4b3d45f
commit 0ca674a313
2 changed files with 14 additions and 0 deletions

View File

@ -84,6 +84,7 @@ public slots:
void readyRead();
void error(QLocalSocket::LocalSocketError socketError);
void redirectMessage(QByteArray& msg);
void pingAlive();
void setType(QString type)
{
@ -145,4 +146,5 @@ private:
bool m_isConnected = false;
QString m_appID;
QTimer m_pingAliveTimer;
};

View File

@ -41,6 +41,9 @@ void ScreenPlaySDK::init()
m_socket.disconnectFromServer();
emit sdkDisconnected();
}
QObject::connect(&m_pingAliveTimer, &QTimer::timeout, this, &ScreenPlaySDK::pingAlive);
m_pingAliveTimer.start(5000);
});
}
@ -152,6 +155,15 @@ void ScreenPlaySDK::redirectMessage(QByteArray& msg)
}
}
void ScreenPlaySDK::pingAlive()
{
m_socket.write("ping");
if (!m_socket.waitForBytesWritten(500)) {
qInfo() << "Cannot ping to main application. Closing!";
emit sdkDisconnected();
}
}
void ScreenPlaySDK::ScreenPlaySDK::redirectMessageOutputToMainWindow(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
Q_UNUSED(type)