diff options
Diffstat (limited to 'Swiften/Server/ServerFromClientSession.cpp')
-rw-r--r-- | Swiften/Server/ServerFromClientSession.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Swiften/Server/ServerFromClientSession.cpp b/Swiften/Server/ServerFromClientSession.cpp index fe4388e..9a3cf83 100644 --- a/Swiften/Server/ServerFromClientSession.cpp +++ b/Swiften/Server/ServerFromClientSession.cpp @@ -32,6 +32,15 @@ ServerFromClientSession::ServerFromClientSession( authenticated_(false), initialized_(false) { xmppLayer_ = boost::shared_ptr<XMPPLayer>(new XMPPLayer(payloadParserFactories_, payloadSerializers_)); + connectionLayer_ = boost::shared_ptr<ConnectionLayer>(new ConnectionLayer(connection_)); + streamStack_ = new StreamStack(xmppLayer_, connectionLayer_); +} + +ServerFromClientSession::~ServerFromClientSession() { + delete streamStack_; +} + +void ServerFromClientSession::start() { xmppLayer_->onStreamStart.connect( boost::bind(&ServerFromClientSession::handleStreamStart, this, _2)); xmppLayer_->onElement.connect( @@ -42,12 +51,7 @@ ServerFromClientSession::ServerFromClientSession( boost::bind(boost::ref(onDataRead), _1)); xmppLayer_->onWriteData.connect( boost::bind(boost::ref(onDataWritten), _1)); - connectionLayer_ = boost::shared_ptr<ConnectionLayer>(new ConnectionLayer(connection_)); - streamStack_ = new StreamStack(xmppLayer_, connectionLayer_); -} - -ServerFromClientSession::~ServerFromClientSession() { - delete streamStack_; + connection_->onDisconnected.connect(boost::bind(&ServerFromClientSession::handleDisconnected, shared_from_this(), _1)); } void ServerFromClientSession::handleElement(boost::shared_ptr<Element> element) { @@ -114,5 +118,9 @@ void ServerFromClientSession::sendStanza(boost::shared_ptr<Stanza> stanza) { xmppLayer_->writeElement(stanza); } +void ServerFromClientSession::handleDisconnected(const boost::optional<Connection::Error>&) { + onSessionFinished(); +} + } |