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/Network/BoostConnection.cpp
parent436ae921afbc5c2b461ee9b2d8fa9b1c869ed274 (diff)
downloadswift-a328466bc492c50c443e406b9325542a75182327.zip
swift-a328466bc492c50c443e406b9325542a75182327.tar.bz2
Implemented clean session/connection shutdown.
Diffstat (limited to 'Swiften/Network/BoostConnection.cpp')
-rw-r--r--Swiften/Network/BoostConnection.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp
index f837b50..d374221 100644
--- a/Swiften/Network/BoostConnection.cpp
+++ b/Swiften/Network/BoostConnection.cpp
@@ -59,7 +59,7 @@ void BoostConnection::connect(const String& domain) {
boost::bind(&BoostConnection::handleConnectFinished, shared_from_this(), boost::asio::placeholders::error));
}
catch (const DomainNameResolveException& e) {
- onError(DomainNameResolveError);
+ onDisconnected(DomainNameResolveError);
}
}
@@ -79,7 +79,7 @@ void BoostConnection::handleConnectFinished(const boost::system::error_code& err
doRead();
}
else if (error != boost::asio::error::operation_aborted) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onError), ConnectionError), shared_from_this());
+ MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), ConnectionError), shared_from_this());
}
}
@@ -94,14 +94,23 @@ void BoostConnection::handleSocketRead(const boost::system::error_code& error, s
MainEventLoop::postEvent(boost::bind(boost::ref(onDataRead), ByteArray(&readBuffer_[0], bytesTransferred)), shared_from_this());
doRead();
}
+ else if (error == boost::asio::error::eof) {
+ MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), boost::optional<Error>()), shared_from_this());
+ }
else if (error != boost::asio::error::operation_aborted) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onError), ReadError), shared_from_this());
+ MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), ReadError), shared_from_this());
}
}
void BoostConnection::handleDataWritten(const boost::system::error_code& error) {
- if (error && error != boost::asio::error::operation_aborted) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onError), WriteError), shared_from_this());
+ if (!error) {
+ return;
+ }
+ if (error == boost::asio::error::eof) {
+ MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), boost::optional<Error>()), shared_from_this());
+ }
+ else if (error && error != boost::asio::error::operation_aborted) {
+ MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), WriteError), shared_from_this());
}
}