summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-12 17:57:48 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-12 18:49:51 (GMT)
commit72858ab262a16aa8db209c2898ab0d3c951a9829 (patch)
tree411ccedbf9bdd746ccb1f124e74fe91111d63a56 /Swiften/Server
parenteb1338be843c53aa02fac0d38455aada3f89db0b (diff)
downloadswift-72858ab262a16aa8db209c2898ab0d3c951a9829.zip
swift-72858ab262a16aa8db209c2898ab0d3c951a9829.tar.bz2
Added ServerFromClientSession.
Diffstat (limited to 'Swiften/Server')
-rw-r--r--Swiften/Server/Makefile.inc1
-rw-r--r--Swiften/Server/ServerFromClientSession.cpp47
-rw-r--r--Swiften/Server/ServerFromClientSession.h41
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_;
+ };
+}