diff options
Diffstat (limited to 'Swiften/Session/BasicSessionStream.cpp')
-rw-r--r-- | Swiften/Session/BasicSessionStream.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp index 3e65640..c44961d 100644 --- a/Swiften/Session/BasicSessionStream.cpp +++ b/Swiften/Session/BasicSessionStream.cpp @@ -37,3 +37,3 @@ BasicSessionStream::BasicSessionStream( tlsOptions_(tlsOptions) { - xmppLayer = new XMPPLayer(payloadParserFactories, payloadSerializers, xmlParserFactory, streamType); + auto xmppLayer = std::make_unique<XMPPLayer>(payloadParserFactories, payloadSerializers, xmlParserFactory, streamType); xmppLayer->onStreamStart.connect(boost::bind(&BasicSessionStream::handleStreamStartReceived, this, _1)); @@ -46,6 +46,4 @@ BasicSessionStream::BasicSessionStream( connection->onDisconnected.connect(boost::bind(&BasicSessionStream::handleConnectionFinished, this, _1)); - connectionLayer = new ConnectionLayer(connection); - - streamStack = new StreamStack(xmppLayer, connectionLayer); + streamStack = std::make_unique<StreamStack>(std::move(xmppLayer), std::unique_ptr<ConnectionLayer>(new ConnectionLayer(connection))); available = true; @@ -59,7 +57,6 @@ BasicSessionStream::~BasicSessionStream() { } - delete streamStack; connection->onDisconnected.disconnect(boost::bind(&BasicSessionStream::handleConnectionFinished, this, _1)); - delete connectionLayer; + auto xmppLayer = streamStack->getLayer<XMPPLayer>(); xmppLayer->onStreamStart.disconnect(boost::bind(&BasicSessionStream::handleStreamStartReceived, this, _1)); @@ -70,3 +67,2 @@ BasicSessionStream::~BasicSessionStream() { xmppLayer->onWriteData.disconnect(boost::bind(&BasicSessionStream::handleDataWritten, this, _1)); - delete xmppLayer; } @@ -75,2 +71,3 @@ void BasicSessionStream::writeHeader(const ProtocolHeader& header) { assert(available); + auto* xmppLayer = streamStack->getLayer<XMPPLayer>(); xmppLayer->writeHeader(header); @@ -80,2 +77,3 @@ void BasicSessionStream::writeElement(std::shared_ptr<ToplevelElement> element) assert(available); + auto* xmppLayer = streamStack->getLayer<XMPPLayer>(); xmppLayer->writeElement(element); @@ -85,2 +83,3 @@ void BasicSessionStream::writeFooter() { assert(available); + auto* xmppLayer = streamStack->getLayer<XMPPLayer>(); xmppLayer->writeFooter(); @@ -90,2 +89,3 @@ void BasicSessionStream::writeData(const std::string& data) { assert(available); + auto* xmppLayer = streamStack->getLayer<XMPPLayer>(); xmppLayer->writeData(data); @@ -164,2 +164,3 @@ void BasicSessionStream::setWhitespacePingEnabled(bool enabled) { void BasicSessionStream::resetXMPPParser() { + auto* xmppLayer = streamStack->getLayer<XMPPLayer>(); xmppLayer->resetParser(); |