Commit 8d466fc6 authored by Leander Schulten's avatar Leander Schulten

Merge branch 'master' into windows-release

parents 24ffafd8 a4e0d81b
Pipeline #206688 passed with stages
in 6 minutes and 55 seconds
......@@ -33,6 +33,7 @@ RemoteVolume::RemoteVolume(Settings &settings) : settings(settings) {
reconnectTimerId = startTimer(WAIT_FOR_RECONNECT_MS);
}
}
killTimer(pingTimer);
});
QObject::connect(&webSocket, &QWebSocket::connected, [this]() {
webSocket.sendTextMessage("Name:" + this->settings.getComputerName());
......@@ -43,6 +44,7 @@ RemoteVolume::RemoteVolume(Settings &settings) : settings(settings) {
killTimer(reconnectTimerId);
reconnectTimerId = -1;
}
pingTimer = startTimer(PING_INTERVALL_MS);
});
QObject::connect(&webSocket, &QWebSocket::textMessageReceived, [](const QString &message) {
bool ok;
......@@ -69,5 +71,8 @@ void RemoteVolume::timerEvent(QTimerEvent *event) {
if (event->timerId() == reconnectTimerId) {
event->accept();
connect();
} else if (event->timerId() == pingTimer) {
event->accept();
webSocket.ping();
}
}
......@@ -10,7 +10,9 @@ class RemoteVolume : public QObject {
QWebSocket webSocket;
Settings &settings;
int reconnectTimerId = -1;
int pingTimer = -1;
static constexpr int WAIT_FOR_RECONNECT_MS = 5 * 1000;
static constexpr int PING_INTERVALL_MS = 59 * 1000;
Q_PROPERTY(bool isConnected READ isConnected NOTIFY isConnectedChanged)
public:
explicit RemoteVolume(Settings &settings);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment