From ff28afc7cf330216e9b5bf8d489f0eb0be8004bf Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Thu, 29 Oct 2015 14:21:59 +0100 Subject: Reconnect to IRC if IRC got disconnected unexpectedly --- src/crsm.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/crsm.cpp') 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; } -- cgit v1.2.3-54-g00ecf