summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-17 19:15:54 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-17 19:15:54 (GMT)
commita328466bc492c50c443e406b9325542a75182327 (patch)
tree8388cb92845a20d5c495e5940f5f16a6b95363a3 /Swiften/Client
parent436ae921afbc5c2b461ee9b2d8fa9b1c869ed274 (diff)
downloadswift-a328466bc492c50c443e406b9325542a75182327.zip
swift-a328466bc492c50c443e406b9325542a75182327.tar.bz2
Implemented clean session/connection shutdown.
Diffstat (limited to 'Swiften/Client')
-rw-r--r--Swiften/Client/Session.cpp32
-rw-r--r--Swiften/Client/Session.h2
-rw-r--r--Swiften/Client/UnitTest/SessionTest.cpp4
3 files changed, 20 insertions, 18 deletions
diff --git a/Swiften/Client/Session.cpp b/Swiften/Client/Session.cpp
index dbeddb7..2f0e076 100644
--- a/Swiften/Client/Session.cpp
+++ b/Swiften/Client/Session.cpp
@@ -44,7 +44,7 @@ void Session::start() {
state_ = Connecting;
connection_ = connectionFactory_->createConnection();
connection_->onConnected.connect(boost::bind(&Session::handleConnected, this));
- connection_->onError.connect(boost::bind(&Session::handleConnectionError, this, _1));
+ connection_->onDisconnected.connect(boost::bind(&Session::handleDisconnected, this, _1));
connection_->connect(jid_.getDomain());
}
@@ -75,20 +75,22 @@ void Session::initializeStreamStack() {
streamStack_ = new StreamStack(xmppLayer_, connectionLayer_);
}
-void Session::handleConnectionError(Connection::Error error) {
- switch (error) {
- case Connection::DomainNameResolveError:
- setError(DomainNameResolveError);
- break;
- case Connection::ReadError:
- setError(ConnectionReadError);
- break;
- case Connection::WriteError:
- setError(ConnectionWriteError);
- break;
- case Connection::ConnectionError:
- setError(ConnectionError);
- break;
+void Session::handleDisconnected(const boost::optional<Connection::Error>& error) {
+ if (error) {
+ switch (*error) {
+ case Connection::DomainNameResolveError:
+ setError(DomainNameResolveError);
+ break;
+ case Connection::ReadError:
+ setError(ConnectionReadError);
+ break;
+ case Connection::WriteError:
+ setError(ConnectionWriteError);
+ break;
+ case Connection::ConnectionError:
+ setError(ConnectionError);
+ break;
+ }
}
}
diff --git a/Swiften/Client/Session.h b/Swiften/Client/Session.h
index 1b4d1fe..17c10b9 100644
--- a/Swiften/Client/Session.h
+++ b/Swiften/Client/Session.h
@@ -87,7 +87,7 @@ namespace Swift {
void sendSessionStart();
void handleConnected();
- void handleConnectionError(Connection::Error);
+ void handleDisconnected(const boost::optional<Connection::Error>&);
void handleElement(boost::shared_ptr<Element>);
void handleStreamStart();
void handleTLSConnected();
diff --git a/Swiften/Client/UnitTest/SessionTest.cpp b/Swiften/Client/UnitTest/SessionTest.cpp
index 5d43736..45c0996 100644
--- a/Swiften/Client/UnitTest/SessionTest.cpp
+++ b/Swiften/Client/UnitTest/SessionTest.cpp
@@ -488,7 +488,7 @@ class SessionTest : public CppUnit::TestFixture {
void connect(const String& domain) {
if (fail_) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onError), Connection::ConnectionError));
+ MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), Connection::ConnectionError));
}
else {
domain_ = domain;
@@ -497,7 +497,7 @@ class SessionTest : public CppUnit::TestFixture {
}
void setError() {
- MainEventLoop::postEvent(boost::bind(boost::ref(onError), Connection::ConnectionError));
+ MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), Connection::ConnectionError));
}
void write(const ByteArray& data) {