Settings: allow disabling websocket

This commit is contained in:
tobtoht
2022-03-04 22:55:29 +01:00
parent 7f73decc41
commit 07d7dfffcb
8 changed files with 76 additions and 2 deletions
+15 -1
View File
@@ -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();