mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-25 02:58:33 +02:00
Settings: allow disabling websocket
This commit is contained in:
@@ -38,15 +38,29 @@ void WebsocketClient::sendMsg(const QByteArray &data) {
|
||||
}
|
||||
|
||||
void WebsocketClient::start() {
|
||||
if (m_stopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
// connect & reconnect on errors/close
|
||||
qDebug() << "WebSocket connect:" << m_url.url();
|
||||
|
||||
auto state = webSocket.state();
|
||||
if (state != QAbstractSocket::ConnectedState && state != QAbstractSocket::ConnectingState) {
|
||||
webSocket.open(m_url);
|
||||
}
|
||||
}
|
||||
|
||||
void WebsocketClient::restart() {
|
||||
m_stopped = false;
|
||||
this->start();
|
||||
}
|
||||
|
||||
void WebsocketClient::stop() {
|
||||
m_stopped = true;
|
||||
webSocket.close();
|
||||
m_connectionTimeout.stop();
|
||||
}
|
||||
|
||||
void WebsocketClient::onConnected() {
|
||||
qDebug() << "WebSocket connected";
|
||||
emit connectionEstablished();
|
||||
|
||||
@@ -16,6 +16,8 @@ class WebsocketClient : public QObject {
|
||||
public:
|
||||
explicit WebsocketClient(QObject *parent = nullptr);
|
||||
void start();
|
||||
void restart();
|
||||
void stop();
|
||||
void sendMsg(const QByteArray &data);
|
||||
|
||||
QWebSocket webSocket;
|
||||
@@ -39,6 +41,7 @@ private:
|
||||
QTimer m_connectionTimeout;
|
||||
int m_timeout = 10;
|
||||
int m_websocketUrlIndex = 0;
|
||||
bool m_stopped = false;
|
||||
};
|
||||
|
||||
#endif //FEATHER_WEBSOCKETCLIENT_H
|
||||
|
||||
@@ -67,6 +67,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
||||
{Config::balanceDisplay, {QS("balanceDisplay"), Config::BalanceDisplay::spendablePlusUnconfirmed}},
|
||||
{Config::inactivityLockEnabled, {QS("inactivityLockEnabled"), false}},
|
||||
{Config::inactivityLockTimeout, {QS("inactivityLockTimeout"), 10}},
|
||||
{Config::disableWebsocket, {QS("disableWebsocket"), false}},
|
||||
|
||||
{Config::multiBroadcast, {QS("multiBroadcast"), true}},
|
||||
{Config::warnOnExternalLink,{QS("warnOnExternalLink"), true}},
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
balanceDisplay,
|
||||
inactivityLockEnabled,
|
||||
inactivityLockTimeout,
|
||||
disableWebsocket,
|
||||
|
||||
multiBroadcast,
|
||||
warnOnExternalLink,
|
||||
|
||||
Reference in New Issue
Block a user