summaryrefslogtreecommitdiffstats
blob: be8b601b440228f3ac544ca1b09f703cccb194d2 (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
#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(
		const String& id,
		boost::shared_ptr<IncomingConnection> connection, 
		PayloadParserFactoryCollection* payloadParserFactories, 
		PayloadSerializerCollection* payloadSerializers) : 
			id_(id),
			connection_(connection), 
			payloadParserFactories_(payloadParserFactories), 
			payloadSerializers_(payloadSerializers) {
	xmppLayer_ = new XMPPLayer(payloadParserFactories_, payloadSerializers_);
	xmppLayer_->onStreamStart.connect(
			boost::bind(&ServerFromClientSession::handleStreamStart, this, _2));
	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) {
	domain_ = domain;
	xmppLayer_->writeHeader(domain_, id_);
}

}