diff options
Diffstat (limited to 'Swiften/Server')
-rw-r--r-- | Swiften/Server/Makefile.inc | 1 | ||||
-rw-r--r-- | Swiften/Server/ServerFromClientSession.cpp | 47 | ||||
-rw-r--r-- | Swiften/Server/ServerFromClientSession.h | 41 |
3 files changed, 89 insertions, 0 deletions
diff --git a/Swiften/Server/Makefile.inc b/Swiften/Server/Makefile.inc index 54f09ce..1ab98d7 100644 --- a/Swiften/Server/Makefile.inc +++ b/Swiften/Server/Makefile.inc @@ -1,5 +1,6 @@ SWIFTEN_SOURCES += \ Swiften/Server/ServerSession.cpp \ + Swiften/Server/ServerFromClientSession.cpp \ Swiften/Server/ServerStanzaRouter.cpp \ Swiften/Server/IncomingConnection.cpp diff --git a/Swiften/Server/ServerFromClientSession.cpp b/Swiften/Server/ServerFromClientSession.cpp new file mode 100644 index 0000000..e85021e --- /dev/null +++ b/Swiften/Server/ServerFromClientSession.cpp @@ -0,0 +1,47 @@ +#include "Swiften/Server/ServerFromClientSession.h" + +#include <boost/bind.hpp> + +#include "Swiften/Network/IncomingConnection.h" +#include "Swiften/StreamStack/StreamStack.h" +#include "Swiften/StreamStack/IncomingConnectionLayer.h" +#include "Swiften/StreamStack/XMPPLayer.h" + +namespace Swift { + +ServerFromClientSession::ServerFromClientSession( + boost::shared_ptr<IncomingConnection> connection, + PayloadParserFactoryCollection* payloadParserFactories, + PayloadSerializerCollection* payloadSerializers) : + connection_(connection), + payloadParserFactories_(payloadParserFactories), + payloadSerializers_(payloadSerializers) { + xmppLayer_ = new XMPPLayer(payloadParserFactories_, payloadSerializers_); + xmppLayer_->onStreamStart.connect( + boost::bind(&ServerFromClientSession::handleStreamStart, this, _1)); + xmppLayer_->onElement.connect( + boost::bind(&ServerFromClientSession::handleElement, this, _1)); + //xmppLayer_->onError.connect( + // boost::bind(&ServerFromClientSession::setError, this, XMLError)); + xmppLayer_->onDataRead.connect( + boost::bind(boost::ref(onDataRead), _1)); + xmppLayer_->onWriteData.connect( + boost::bind(boost::ref(onDataWritten), _1)); + connectionLayer_ = new IncomingConnectionLayer(connection_.get()); + streamStack_ = new StreamStack(xmppLayer_, connectionLayer_); +} + +ServerFromClientSession::~ServerFromClientSession() { + delete streamStack_; + delete connectionLayer_; + delete xmppLayer_; +} + +void ServerFromClientSession::handleElement(boost::shared_ptr<Element>) { +} + +void ServerFromClientSession::handleStreamStart(const String& domain) { + xmppLayer_->writeHeader(domain); +} + +} diff --git a/Swiften/Server/ServerFromClientSession.h b/Swiften/Server/ServerFromClientSession.h new file mode 100644 index 0000000..cedfcdb --- /dev/null +++ b/Swiften/Server/ServerFromClientSession.h @@ -0,0 +1,41 @@ +#pragma once + +#include <boost/shared_ptr.hpp> +#include <boost/signal.hpp> + +namespace Swift { + class Element; + class PayloadParserFactoryCollection; + class PayloadSerializerCollection; + class StreamStack; + class XMPPLayer; + class IncomingConnectionLayer; + class IncomingConnection; + class ByteArray; + class String; + + class ServerFromClientSession { + public: + ServerFromClientSession( + boost::shared_ptr<IncomingConnection> connection, + PayloadParserFactoryCollection* payloadParserFactories, + PayloadSerializerCollection* payloadSerializers); + ~ServerFromClientSession(); + + boost::signal<void()> onSessionFinished; + boost::signal<void (const ByteArray&)> onDataWritten; + boost::signal<void (const ByteArray&)> onDataRead; + + private: + void handleElement(boost::shared_ptr<Element>); + void handleStreamStart(const String& domain); + + private: + boost::shared_ptr<IncomingConnection> connection_; + PayloadParserFactoryCollection* payloadParserFactories_; + PayloadSerializerCollection* payloadSerializers_; + IncomingConnectionLayer* connectionLayer_; + StreamStack* streamStack_; + XMPPLayer* xmppLayer_; + }; +} |