Detect wakeup from hibernate, re-establish websocket connection
This commit is contained in:
parent
0e37f97aa2
commit
49b55768f7
|
@ -111,6 +111,24 @@ AppContext::AppContext(QCommandLineParser *cmdargs) {
|
||||||
this->storeWallet();
|
this->storeWallet();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If system clock skewed for >= 300 seconds, assume a wake-up from hibernate and reload the websocket connection
|
||||||
|
if(!this->isAndroid)
|
||||||
|
m_hibernateTimer.start(3 * 1000);
|
||||||
|
|
||||||
|
m_hibernatePreviousTime = std::chrono::steady_clock::now();
|
||||||
|
connect(&m_hibernateTimer, &QTimer::timeout, [this]() {
|
||||||
|
const auto now = std::chrono::steady_clock::now();
|
||||||
|
const auto elapsed = now - m_hibernatePreviousTime;
|
||||||
|
|
||||||
|
if(elapsed >= m_hibernateDetectInterval) {
|
||||||
|
qCritical() << "Clock skew detected, resetting websocket connection";
|
||||||
|
this->ws->webSocket.abort();
|
||||||
|
this->ws->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hibernatePreviousTime = now;
|
||||||
|
});
|
||||||
|
|
||||||
// restore height lookup
|
// restore height lookup
|
||||||
this->initRestoreHeights();
|
this->initRestoreHeights();
|
||||||
|
|
||||||
|
|
|
@ -221,6 +221,9 @@ private:
|
||||||
WalletKeysFilesModel *m_walletKeysFilesModel;
|
WalletKeysFilesModel *m_walletKeysFilesModel;
|
||||||
const int m_donationBoundary = 15;
|
const int m_donationBoundary = 15;
|
||||||
QTimer m_storeTimer;
|
QTimer m_storeTimer;
|
||||||
|
QTimer m_hibernateTimer;
|
||||||
|
std::chrono::seconds m_hibernateDetectInterval{300};
|
||||||
|
std::chrono::time_point<std::chrono::steady_clock> m_hibernatePreviousTime;
|
||||||
|
|
||||||
void setupPathsUnix();
|
void setupPathsUnix();
|
||||||
void setupPathsWindows();
|
void setupPathsWindows();
|
||||||
|
|
Loading…
Reference in New Issue