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/Session.cpp
parent436ae921afbc5c2b461ee9b2d8fa9b1c869ed274 (diff)
downloadswift-a328466bc492c50c443e406b9325542a75182327.zip
swift-a328466bc492c50c443e406b9325542a75182327.tar.bz2
Implemented clean session/connection shutdown.
Diffstat (limited to 'Swiften/Client/Session.cpp')
-rw-r--r--Swiften/Client/Session.cpp32
1 files changed, 17 insertions, 15 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;
+ }
}
}