summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/LinkLocal/LinkLocalSession.h')
-rw-r--r--Swiften/LinkLocal/LinkLocalSession.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/Swiften/LinkLocal/LinkLocalSession.h b/Swiften/LinkLocal/LinkLocalSession.h
new file mode 100644
index 0000000..9a7ac13
--- /dev/null
+++ b/Swiften/LinkLocal/LinkLocalSession.h
@@ -0,0 +1,82 @@
+#pragma once
+
+#include <boost/shared_ptr.hpp>
+#include <boost/signal.hpp>
+#include <boost/enable_shared_from_this.hpp>
+
+#include "Swiften/JID/JID.h"
+#include "Swiften/Elements/Element.h"
+#include "Swiften/Network/Connection.h"
+#include "Swiften/StreamStack/ConnectionLayer.h"
+
+namespace Swift {
+ class ProtocolHeader;
+ class StreamStack;
+ class JID;
+ class Stanza;
+ class ByteArray;
+ class PayloadParserFactoryCollection;
+ class PayloadSerializerCollection;
+ class XMPPLayer;
+
+ class LinkLocalSession :
+ public boost::enable_shared_from_this<LinkLocalSession> {
+ public:
+ LinkLocalSession(
+ const JID& localJID,
+ boost::shared_ptr<Connection> connection,
+ PayloadParserFactoryCollection* payloadParserFactories,
+ PayloadSerializerCollection* payloadSerializers);
+ virtual ~LinkLocalSession();
+
+ void finishSession();
+
+ // TODO: Make non-virtual when OutgoingSession is fixed
+ virtual void sendStanza(boost::shared_ptr<Stanza>);
+
+ virtual const JID& getRemoteJID() const = 0;
+
+ virtual void start() = 0;
+
+ boost::signal<void (boost::shared_ptr<Stanza>)> onStanzaReceived;
+ boost::signal<void ()> onSessionFinished;
+ boost::signal<void ()> onSessionStarted;
+ boost::signal<void (const ByteArray&)> onDataWritten;
+ boost::signal<void (const ByteArray&)> onDataRead;
+
+ protected:
+ void initializeStreamStack();
+
+ const JID& getLocalJID() const {
+ return localJID;
+ }
+
+ boost::shared_ptr<XMPPLayer> getXMPPLayer() const {
+ return xmppLayer;
+ }
+
+ // TODO: Remove later
+ void setConnection(boost::shared_ptr<Connection> c) {
+ connection = c;
+ }
+
+ virtual void handleElement(boost::shared_ptr<Element>) = 0;
+ virtual void handleStreamStart(const ProtocolHeader&) = 0;
+
+ void setInitialized();
+ bool isInitialized() const { return initialized; }
+
+ private:
+ void handleDisconnected(const boost::optional<Connection::Error>& error);
+
+ private:
+ JID localJID;
+ PayloadParserFactoryCollection* payloadParserFactories;
+ PayloadSerializerCollection* payloadSerializers;
+ boost::shared_ptr<Connection> connection;
+ boost::shared_ptr<XMPPLayer> xmppLayer;
+ boost::shared_ptr<ConnectionLayer> connectionLayer;
+ StreamStack* streamStack;
+ bool initialized;
+ };
+}