diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-06-28 21:12:19 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-06-28 21:12:19 (GMT) |
commit | d0c6b19035623a8b247f8c4eb7f72d616d4efac2 (patch) | |
tree | 5c48e9fe1451e958db95c30266d8e81bb787b182 /Swift/Controllers/MainController.cpp | |
parent | 0b4d42cce98c712d7117a4bfa5606464bb7103f2 (diff) | |
download | swift-d0c6b19035623a8b247f8c4eb7f72d616d4efac2.zip swift-d0c6b19035623a8b247f8c4eb7f72d616d4efac2.tar.bz2 |
Improve reconnect logic.
Expire old connection error notices, and correctly back-off repeated
connection failures.
Resolves: #479
Resolves: #480
Diffstat (limited to 'Swift/Controllers/MainController.cpp')
-rw-r--r-- | Swift/Controllers/MainController.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 1265979..a277051 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -139,6 +139,7 @@ MainController::~MainController() { void MainController::resetClient() { resetCurrentError(); + resetPendingReconnects(); serverDiscoInfo_ = boost::shared_ptr<DiscoInfo>(); xmppRoster_ = boost::shared_ptr<XMPPRoster>(); delete chatsManager_; @@ -175,6 +176,7 @@ void MainController::resetPendingReconnects() { reconnectTimer_->stop(); reconnectTimer_.reset(); } + resetCurrentError(); } void MainController::resetCurrentError() { @@ -261,6 +263,7 @@ void MainController::handleChangeStatusRequest(StatusShow::Type show, const Stri if (show == StatusShow::None) { // FIXME: This is wrong. None doesn't mean unavailable presence->setType(Presence::Unavailable); + resetPendingReconnects(); } else { presence->setShow(show); @@ -373,6 +376,7 @@ void MainController::handleError(const ClientError& error) { std::stringstream ss; ss << "Reconnect to " << jid_.getDomain() << " failed: " << message << ". Will retry in " << timeBeforeNextReconnect_ << " seconds."; message = ss.str(); + lastDisconnectError_->conclude(); } else { message = "Disconnected from " + jid_.getDomain() + ": " + message; } @@ -386,7 +390,7 @@ void MainController::setReconnectTimer() { if (timeBeforeNextReconnect_ < 0) { timeBeforeNextReconnect_ = 1; } else { - timeBeforeNextReconnect_ = timeBeforeNextReconnect_ >= 150 ? 300 : timeBeforeNextReconnect_ * 2; + timeBeforeNextReconnect_ = timeBeforeNextReconnect_ >= 150 ? 300 : timeBeforeNextReconnect_ * 2; // Randomly selected by roll of a die, as required by 3920bis } if (reconnectTimer_) { reconnectTimer_->stop(); @@ -410,7 +414,6 @@ void MainController::signOut() { void MainController::logout() { systemTrayController_->setMyStatusType(StatusShow::None); - resetPendingReconnects(); if (client_ /*&& client_->isAvailable()*/) { client_->disconnect(); } |