mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-18 08:22:33 +02: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:
parent
41a4b3d45f
commit
0ca674a313
@ -84,6 +84,7 @@ public slots:
|
|||||||
void readyRead();
|
void readyRead();
|
||||||
void error(QLocalSocket::LocalSocketError socketError);
|
void error(QLocalSocket::LocalSocketError socketError);
|
||||||
void redirectMessage(QByteArray& msg);
|
void redirectMessage(QByteArray& msg);
|
||||||
|
void pingAlive();
|
||||||
|
|
||||||
void setType(QString type)
|
void setType(QString type)
|
||||||
{
|
{
|
||||||
@ -145,4 +146,5 @@ private:
|
|||||||
bool m_isConnected = false;
|
bool m_isConnected = false;
|
||||||
|
|
||||||
QString m_appID;
|
QString m_appID;
|
||||||
|
QTimer m_pingAliveTimer;
|
||||||
};
|
};
|
||||||
|
@ -41,6 +41,9 @@ void ScreenPlaySDK::init()
|
|||||||
m_socket.disconnectFromServer();
|
m_socket.disconnectFromServer();
|
||||||
emit sdkDisconnected();
|
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)
|
void ScreenPlaySDK::ScreenPlaySDK::redirectMessageOutputToMainWindow(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||||
{
|
{
|
||||||
Q_UNUSED(type)
|
Q_UNUSED(type)
|
||||||
|
Loading…
Reference in New Issue
Block a user