Try to improve Twitch IRC network stability (#2347)

This commit is contained in:
pajlada
2021-01-09 18:05:02 +01:00
committed by GitHub
parent d0deb44abf
commit b3e01a40d7
5 changed files with 49 additions and 8 deletions
+21
View File
@@ -62,6 +62,8 @@ AbstractIrcServer::AbstractIrcServer()
// listen to reconnect request
this->readConnection_->reconnectRequested.connect([this] {
this->addGlobalSystemMessage(
"Server connection timed out, reconnecting");
this->connect();
});
// this->writeConnection->reconnectRequested.connect([this] {
@@ -135,6 +137,25 @@ void AbstractIrcServer::open(ConnectionType type)
}
}
void AbstractIrcServer::addGlobalSystemMessage(QString messageText)
{
std::lock_guard<std::mutex> lock(this->channelMutex);
MessageBuilder b(systemMessage, messageText);
auto message = b.release();
for (std::weak_ptr<Channel> &weak : this->channels.values())
{
std::shared_ptr<Channel> chan = weak.lock();
if (!chan)
{
continue;
}
chan->addMessage(message);
}
}
void AbstractIrcServer::disconnect()
{
std::lock_guard<std::mutex> locker(this->connectionMutex_);