mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added comments for explanation
This commit is contained in:
parent
5673cefd1b
commit
02214c38a6
|
@ -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,
|
||||
|
|
|
@ -81,6 +81,7 @@ std::shared_ptr<Channel> 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<Channel> 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 =
|
||||
|
|
Loading…
Reference in a new issue