Browse Source

Try to avoid coredumping from QT internal bugs relating to websocket->isValid()

pull/102/head
Jonathan "Duke" Leto 5 years ago
parent
commit
06a63a389a
  1. 16
      src/websockets.cpp

16
src/websockets.cpp

@ -211,14 +211,18 @@ void WormholeClient::onConnected()
qDebug() << "Created QTimer";
QObject::connect(timer, &QTimer::timeout, [=]() {
qDebug() << "Timer timeout!";
if (!shuttingDown && m_webSocket && m_webSocket->isValid()) {
auto payload = QJsonDocument(QJsonObject { {"ping", "ping"} }).toJson();
qint64 bytes = m_webSocket->sendTextMessage(payload);
qDebug() << "Sent ping, " << bytes << " bytes";
try {
if (!shuttingDown && m_webSocket && m_webSocket->isValid()) {
auto payload = QJsonDocument(QJsonObject { {"ping", "ping"} }).toJson();
qint64 bytes = m_webSocket->sendTextMessage(payload);
qDebug() << "Sent ping, " << bytes << " bytes";
}
} catch (...) {
qDebug() << "Websocket is invalid, no ping sent!";
}
});
unsigned int interval = 4*60*1000;
timer->start(interval); // 4 minutes
unsigned int interval = 1*60*1000; // 1 minute
timer->start(interval);
qDebug() << "Started timer with interval=" << interval;
} else {
qDebug() << "Invalid websocket object onConnected!";

Loading…
Cancel
Save