summaryrefslogtreecommitdiffstats
blob: 62e89ef32bede462b0c86d227df1051502a87f85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once

#include <boost/shared_ptr.hpp>
#include <boost/signal.hpp>

#include "Swiften/Base/String.h"
#include "Swiften/JID/JID.h"

namespace Swift {
	class Element;
	class Stanza;
	class PayloadParserFactoryCollection;
	class PayloadSerializerCollection;
	class StreamStack;
	class UserRegistry;
	class XMPPLayer;
	class ConnectionLayer;
	class Connection;
	class ByteArray;

	class ServerFromClientSession {
		public:
			ServerFromClientSession(
					const String& id,
					boost::shared_ptr<Connection> connection, 
					PayloadParserFactoryCollection* payloadParserFactories, 
					PayloadSerializerCollection* payloadSerializers,
					UserRegistry* userRegistry);
			~ServerFromClientSession();

			void sendStanza(boost::shared_ptr<Stanza>);

			const JID& getJID() const {
				return jid_;
			}

			const JID& getDomain() const {
				return domain_;
			}

			boost::signal<void (boost::shared_ptr<Stanza>)> onStanzaReceived;
			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:
			String id_;
			boost::shared_ptr<Connection> connection_;
			PayloadParserFactoryCollection* payloadParserFactories_;
			PayloadSerializerCollection* payloadSerializers_;
			UserRegistry* userRegistry_;
			bool authenticated_;
			bool initialized_;
			boost::shared_ptr<XMPPLayer> xmppLayer_;
			boost::shared_ptr<ConnectionLayer> connectionLayer_;
			StreamStack* streamStack_;
			JID domain_;
			String user_;
			JID jid_;
	};
}