From 02214c38a6be8bc0efb972828757e50da99ed4ff Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 24 Jun 2018 12:16:32 +0200 Subject: [PATCH] added comments for explanation --- src/providers/irc/ircconnection2.cpp | 2 ++ src/providers/twitch/twitchserver.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/providers/irc/ircconnection2.cpp b/src/providers/irc/ircconnection2.cpp index 8469bed1c..ac4257576 100644 --- a/src/providers/irc/ircconnection2.cpp +++ b/src/providers/irc/ircconnection2.cpp @@ -7,6 +7,7 @@ namespace irc { IrcConnection::IrcConnection(QObject *parent) : Communi::IrcConnection(parent) { + // send ping every x seconds this->pingTimer_.setInterval(5000); this->pingTimer_.start(); QObject::connect(&this->pingTimer_, &QTimer::timeout, [this] { @@ -17,6 +18,7 @@ IrcConnection::IrcConnection(QObject *parent) this->recentlyReceivedMessage_ = false; }); + // reconnect after x seconds without receiving a message this->reconnectTimer_.setInterval(5000); this->reconnectTimer_.setSingleShot(true); QObject::connect(&this->reconnectTimer_, &QTimer::timeout, diff --git a/src/providers/twitch/twitchserver.cpp b/src/providers/twitch/twitchserver.cpp index 113ec6e52..af393d227 100644 --- a/src/providers/twitch/twitchserver.cpp +++ b/src/providers/twitch/twitchserver.cpp @@ -81,6 +81,7 @@ std::shared_ptr TwitchServer::createChannel(const QString &channelName) QTime now = QTime::currentTime(); + // check if you are sending messages too fast if (lastMessage.size() > 0 && lastMessage.back().addMSecs(channel->hasModRights() ? 100 : 1100) > now) { if (lastErrorTimeSpeed.addSecs(30) < now) { @@ -94,10 +95,12 @@ std::shared_ptr TwitchServer::createChannel(const QString &channelName) return; } + // remove messages older than 30 seconds while (lastMessage.size() > 0 && lastMessage.front().addSecs(32) < now) { lastMessage.pop(); } + // check if you are sending too many messages if (lastMessage.size() >= maxMessageCount) { if (lastErrorTimeAmount.addSecs(30) < now) { auto errorMessage =