summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-19 12:27:15 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-19 12:27:15 (GMT)
commit9ccf1973ec3e23e4ba061b774c3f3e3bde4f1040 (patch)
tree4f760b6223c1ca5ef95ee3a261a0f2ec13b963a5 /Swiften/Session/Session.h
parent1de12ed346fc0018527afe082886129088e27a95 (diff)
downloadswift-9ccf1973ec3e23e4ba061b774c3f3e3bde4f1040.zip
swift-9ccf1973ec3e23e4ba061b774c3f3e3bde4f1040.tar.bz2
Rename Session to ClientSession.
Diffstat (limited to 'Swiften/Session/Session.h')
-rw-r--r--Swiften/Session/Session.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/Swiften/Session/Session.h b/Swiften/Session/Session.h
new file mode 100644
index 0000000..bf8049a
--- /dev/null
+++ b/Swiften/Session/Session.h
@@ -0,0 +1,76 @@
+#pragma once
+
+#include <boost/shared_ptr.hpp>
+#include <boost/signal.hpp>
+#include <boost/optional.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 Session : public boost::enable_shared_from_this<Session> {
+ public:
+ enum Error {
+ ConnectionError,
+ XMLError
+ };
+
+ Session(
+ boost::shared_ptr<Connection> connection,
+ PayloadParserFactoryCollection* payloadParserFactories,
+ PayloadSerializerCollection* payloadSerializers);
+ virtual ~Session();
+
+ void startSession();
+ void finishSession();
+ void sendStanza(boost::shared_ptr<Stanza>);
+
+ boost::signal<void (boost::shared_ptr<Stanza>)> onStanzaReceived;
+ boost::signal<void ()> onSessionStarted;
+ boost::signal<void (const boost::optional<Error>&)> onSessionFinished;
+ boost::signal<void (const ByteArray&)> onDataWritten;
+ boost::signal<void (const ByteArray&)> onDataRead;
+
+ protected:
+ void finishSession(const Error&);
+
+ virtual void handleSessionStarted() {}
+ virtual void handleElement(boost::shared_ptr<Element>) = 0;
+ virtual void handleStreamStart(const ProtocolHeader&) = 0;
+
+ void initializeStreamStack();
+
+ boost::shared_ptr<XMPPLayer> getXMPPLayer() const {
+ return xmppLayer;
+ }
+
+ void setInitialized();
+ bool isInitialized() const {
+ return initialized;
+ }
+
+ private:
+ void handleDisconnected(const boost::optional<Connection::Error>& error);
+
+ private:
+ boost::shared_ptr<Connection> connection;
+ PayloadParserFactoryCollection* payloadParserFactories;
+ PayloadSerializerCollection* payloadSerializers;
+ boost::shared_ptr<XMPPLayer> xmppLayer;
+ boost::shared_ptr<ConnectionLayer> connectionLayer;
+ StreamStack* streamStack;
+ bool initialized;
+ };
+}