summaryrefslogtreecommitdiffstats
path: root/src/crsm.cpp
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2015-10-29 14:21:59 +0100
committerMarkus Mittendrein <git@maxmitti.tk>2015-10-29 14:21:59 +0100
commitff28afc7cf330216e9b5bf8d489f0eb0be8004bf (patch)
tree8764f3c3068e53fd63f0f70ffc00caf459f172eb /src/crsm.cpp
parent3a6d73e82f3e226970bb3b9dc00f9a57ce136e4d (diff)
downloadmanager-ff28afc7cf330216e9b5bf8d489f0eb0be8004bf.tar.gz
manager-ff28afc7cf330216e9b5bf8d489f0eb0be8004bf.zip
Reconnect to IRC if IRC got disconnected unexpectedly
Diffstat (limited to 'src/crsm.cpp')
-rw-r--r--src/crsm.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/crsm.cpp b/src/crsm.cpp
index 4f1b625..73828b6 100644
--- a/src/crsm.cpp
+++ b/src/crsm.cpp
@@ -487,6 +487,14 @@ void CRSM::ircMessageReceived(IrcMessage *message)
}
}
+void CRSM::ircDisconnected()
+{
+ if(!finish)
+ {
+ reconnectIrc();
+ }
+}
+
void CRSM::greet(QString pcName)
{
if(!Session.Clonk.Clients.contains(pcName))
@@ -1537,9 +1545,17 @@ void CRSM::prepareAndConnectIrc()
connection->setPassword(Config.IRC.Password);
connect(connection, SIGNAL(messageReceived(IrcMessage*)), this, SLOT(ircMessageReceived(IrcMessage*)));
+ connect(connection, SIGNAL(disconnected()), this, SLOT(ircDisconnected()));
connection->open();
}
+void CRSM::reconnectIrc()
+{
+ connection->close();
+ delete connection;
+ prepareAndConnectIrc();
+}
+
ClientInfo &CRSM::getClientInfo(const QString &pcName, int cuid, const QString &user)
{
if(!Session.Clonk.Clients.contains(pcName))
@@ -2207,9 +2223,7 @@ CMD_FUNCTION_IMPL(saveConfig)
CMD_FUNCTION_IMPL(reconnectIrc)
respond(client, "Reconnecting...\n");
- connection->close();
- delete connection;
- prepareAndConnectIrc();
+ reconnectIrc();
return Success;
}