diff options
author | Tobias Markmann <tm@ayena.de> | 2018-08-02 09:00:25 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2018-08-02 09:00:25 (GMT) |
commit | 091f6e520694360a0407ab0cf3bb036fb461e6e3 (patch) | |
tree | 717ff863e8cd799842e5c82fc2d833ae026c9b20 /Swiften/Session/BasicSessionStream.cpp | |
parent | 80f74201f0a35718642e434c58b631b238fd85df (diff) | |
download | swift-091f6e520694360a0407ab0cf3bb036fb461e6e3.zip swift-091f6e520694360a0407ab0cf3bb036fb461e6e3.tar.bz2 |
Have StreamStack own the top and bottom layer
Test-Information:
Builds, unit tests and integration tests pass on macOS with
clang 7.0 master.
Change-Id: I0db411e49339ccb2301edd1a16612cb1ad2c927c
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(); |