summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHanzZ <hanzz.k@gmail.com>2011-10-23 12:20:52 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-11-18 20:19:27 (GMT)
commit7df402e9319b3ee2ce3c4d6e07a978f853b7a02e (patch)
tree2012872518c6ace48156469efda34282be928717 /Swiften
parent184909e229c3e7b702099d69c0192c500d750e68 (diff)
downloadswift-7df402e9319b3ee2ce3c4d6e07a978f853b7a02e.zip
swift-7df402e9319b3ee2ce3c4d6e07a978f853b7a02e.tar.bz2
Emit onSessionFinished only in Session::handleDisconnected.
Copyright (c) 2011 Jan Kaluza Licensed under the Simplified BSD license. See Documentation/Licenses/BSD-simplified.txt for more information.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Session/Session.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/Swiften/Session/Session.cpp b/Swiften/Session/Session.cpp
index 661cb8d..0eef997 100644
--- a/Swiften/Session/Session.cpp
+++ b/Swiften/Session/Session.cpp
@@ -48,8 +48,6 @@ void Session::finishSession() {
xmppLayer->writeFooter();
}
connection->disconnect();
- handleSessionFinished(boost::optional<SessionError>());
- onSessionFinished(boost::optional<SessionError>());
}
void Session::finishSession(const SessionError& error) {
@@ -61,21 +59,19 @@ void Session::finishSession(const SessionError& error) {
xmppLayer->writeFooter();
}
connection->disconnect();
- handleSessionFinished(boost::optional<SessionError>(error));
- onSessionFinished(boost::optional<SessionError>(error));
}
void Session::initializeStreamStack() {
xmppLayer = new XMPPLayer(payloadParserFactories, payloadSerializers, xmlParserFactory, ClientStreamType);
xmppLayer->onStreamStart.connect(
- boost::bind(&Session::handleStreamStart, shared_from_this(), _1));
- xmppLayer->onElement.connect(boost::bind(&Session::handleElement, shared_from_this(), _1));
+ boost::bind(&Session::handleStreamStart, this, _1));
+ xmppLayer->onElement.connect(boost::bind(&Session::handleElement, this, _1));
xmppLayer->onError.connect(
- boost::bind(&Session::finishSession, shared_from_this(), XMLError));
+ boost::bind(&Session::finishSession, this, XMLError));
xmppLayer->onDataRead.connect(boost::bind(boost::ref(onDataRead), _1));
xmppLayer->onWriteData.connect(boost::bind(boost::ref(onDataWritten), _1));
connection->onDisconnected.connect(
- boost::bind(&Session::handleDisconnected, shared_from_this(), _1));
+ boost::bind(&Session::handleDisconnected, this, _1));
connectionLayer = new ConnectionLayer(connection);
streamStack = new StreamStack(xmppLayer, connectionLayer);
}
@@ -85,18 +81,24 @@ void Session::sendElement(boost::shared_ptr<Element> stanza) {
}
void Session::handleDisconnected(const boost::optional<Connection::Error>& connectionError) {
+ connection->onDisconnected.disconnect(
+ boost::bind(&Session::handleDisconnected, this, _1));
if (connectionError) {
switch (*connectionError) {
case Connection::ReadError:
- finishSession(ConnectionReadError);
+ handleSessionFinished(ConnectionReadError);
+ onSessionFinished(ConnectionReadError);
break;
case Connection::WriteError:
- finishSession(ConnectionWriteError);
+ handleSessionFinished(ConnectionWriteError);
+ onSessionFinished(ConnectionWriteError);
break;
}
}
else {
- finishSession();
+ boost::optional<SessionError> error;
+ handleSessionFinished(error);
+ onSessionFinished(error);
}
}