2018-06-04 21:05:18 +02:00
|
|
|
#include "ircconnection2.hpp"
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
namespace providers {
|
|
|
|
namespace irc {
|
|
|
|
|
|
|
|
IrcConnection::IrcConnection(QObject *parent)
|
|
|
|
: Communi::IrcConnection(parent)
|
|
|
|
{
|
2018-06-04 21:37:19 +02:00
|
|
|
this->pingTimer_.setInterval(10000);
|
|
|
|
this->pingTimer_.start();
|
|
|
|
QObject::connect(&this->pingTimer_, &QTimer::timeout, [this] {
|
|
|
|
if (!this->recentlyReceivedMessage_.load()) {
|
|
|
|
this->sendRaw("PING");
|
|
|
|
this->reconnectTimer_.start();
|
|
|
|
}
|
|
|
|
this->recentlyReceivedMessage_ = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
this->reconnectTimer_.setInterval(10000);
|
|
|
|
this->reconnectTimer_.setSingleShot(true);
|
|
|
|
QObject::connect(&this->reconnectTimer_, &QTimer::timeout,
|
|
|
|
[this] { reconnectRequested.invoke(); });
|
|
|
|
|
|
|
|
QObject::connect(this, &Communi::IrcConnection::messageReceived,
|
|
|
|
[this](Communi::IrcMessage *message) {
|
|
|
|
if (message->command() == "PONG") {
|
|
|
|
qDebug() << "PONG";
|
|
|
|
}
|
|
|
|
this->recentlyReceivedMessage_ = true;
|
|
|
|
|
|
|
|
if (this->reconnectTimer_.isActive()) {
|
|
|
|
this->reconnectTimer_.stop();
|
|
|
|
qDebug() << "reconnect stopped";
|
|
|
|
}
|
|
|
|
});
|
2018-06-04 21:05:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace irc
|
|
|
|
} // namespace providers
|
|
|
|
} // namespace chatterino
|