Try to improve Twitch IRC network stability (#2347)
This commit is contained in:
@@ -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_);
|
||||
|
||||
Reference in New Issue
Block a user