summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-10 22:36:26 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-10 22:36:26 (GMT)
commit6a20be61e229255f93d55f13be3346525698237a (patch)
treec7ed9949826b554297100267c560b2435c043955 /Swiften
parentd6322619cdfd34e62126cd9b8a09d95316fff6ae (diff)
downloadswift-6a20be61e229255f93d55f13be3346525698237a.zip
swift-6a20be61e229255f93d55f13be3346525698237a.tar.bz2
Close connection properly on disconnect and session end.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Client/Client.cpp7
-rw-r--r--Swiften/Client/Client.h2
2 files changed, 8 insertions, 1 deletions
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index 1b662f5..85db4ac 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -33,6 +33,7 @@ bool Client::isAvailable() {
}
void Client::connect() {
+ assert(!connection_);
DomainNameResolver resolver;
try {
HostAddressPort remote = resolver.resolve(jid_.getDomain().getUTF8String());
@@ -73,6 +74,10 @@ void Client::disconnect() {
session_->finish();
session_.reset();
}
+ closeConnection();
+}
+
+void Client::closeConnection() {
if (connection_) {
connection_->disconnect();
connection_.reset();
@@ -124,6 +129,7 @@ void Client::setCertificate(const String& certificate) {
}
void Client::handleSessionFinished(boost::shared_ptr<Error> error) {
+ closeConnection();
if (error) {
ClientError clientError;
if (boost::shared_ptr<ClientSession::Error> actualError = boost::dynamic_pointer_cast<ClientSession::Error>(error)) {
@@ -172,6 +178,7 @@ void Client::handleSessionFinished(boost::shared_ptr<Error> error) {
}
onError(clientError);
}
+ session_.reset();
}
void Client::handleNeedCredentials() {
diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h
index 5188789..3f7d350 100644
--- a/Swiften/Client/Client.h
+++ b/Swiften/Client/Client.h
@@ -55,7 +55,7 @@ namespace Swift {
void handleDataRead(const String&);
void handleDataWritten(const String&);
- void reset();
+ void closeConnection();
private:
JID jid_;