fix: request more historical messages on wake (#5018)

This commit is contained in:
iProdigy
2023-12-16 06:38:35 -06:00
committed by GitHub
parent 5f8c4c6b66
commit e75ce5db54
8 changed files with 48 additions and 19 deletions
+14 -1
View File
@@ -85,6 +85,9 @@ AbstractIrcServer::AbstractIrcServer()
}
this->readConnection_->smartReconnect();
});
this->connections_.managedConnect(this->readConnection_->heartbeat, [this] {
this->markChannelsConnected();
});
}
void AbstractIrcServer::initializeIrc()
@@ -358,11 +361,21 @@ void AbstractIrcServer::onDisconnected()
if (auto *channel = dynamic_cast<TwitchChannel *>(chan.get()))
{
channel->markDisconnectedNow();
channel->markDisconnected();
}
}
}
void AbstractIrcServer::markChannelsConnected()
{
this->forEachChannel([](const ChannelPtr &chan) {
if (auto *channel = dynamic_cast<TwitchChannel *>(chan.get()))
{
channel->markConnected();
}
});
}
std::shared_ptr<Channel> AbstractIrcServer::getCustomChannel(
const QString &channelName)
{
+1
View File
@@ -73,6 +73,7 @@ protected:
virtual void onReadConnected(IrcConnection *connection);
virtual void onWriteConnected(IrcConnection *connection);
virtual void onDisconnected();
void markChannelsConnected();
virtual std::shared_ptr<Channel> getCustomChannel(
const QString &channelName);
+1
View File
@@ -64,6 +64,7 @@ IrcConnection::IrcConnection(QObject *parent)
// If we're still receiving messages, all is well
this->recentlyReceivedMessage_ = false;
this->waitingForPong_ = false;
this->heartbeat.invoke();
return;
}
+3
View File
@@ -19,6 +19,9 @@ public:
// receiver to trigger a reconnect, if desired
pajlada::Signals::Signal<bool> connectionLost;
// Signal to indicate the connection is still healthy
pajlada::Signals::NoArgSignal heartbeat;
// Request a reconnect with a minimum interval between attempts.
// This won't violate RECONNECT_MIN_INTERVAL
void smartReconnect();