blob: 5ce9e31f2c106a32fee968817fea4e4f75fd56c5 (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#pragma once
#include <boost/shared_ptr.hpp>
#include <vector>
#include "Swiften/Network/BoostConnection.h"
#include "Swiften/Network/BoostIOServiceThread.h"
#include "Swiften/Network/BoostConnectionServer.h"
#include "Swiften/Server/UserRegistry.h"
#include "Swiften/Base/IDGenerator.h"
#include "Swiften/Network/Connection.h"
#include "Swiften/LinkLocal/DNSSDService.h"
#include "Swiften/LinkLocal/LinkLocalRoster.h"
#include "Swiften/Session/SessionTracer.h"
#include "Swiften/Server/ServerFromClientSession.h"
#include "Swiften/Elements/Element.h"
#include "Swiften/LinkLocal/LinkLocalConnector.h"
#include "Swiften/JID/JID.h"
#include "Swiften/Elements/Presence.h"
#include "Swiften/Elements/RosterPayload.h"
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
namespace Swift {
class Server {
public:
Server(int clientConnectionPort, int linkLocalConnectionPort, boost::shared_ptr<DNSSDService> dnsSDService);
boost::signal<void (bool)> onSelfConnected;
private:
void handleNewClientConnection(boost::shared_ptr<Connection> c);
void handleNewLinkLocalConnection(boost::shared_ptr<Connection> connection);
void handleServiceRegistered(const DNSSDService::Service& service);
void handleSessionStarted();
void handleSessionFinished(boost::shared_ptr<ServerFromClientSession>);
void handleLinkLocalSessionFinished(boost::shared_ptr<Session> session);
void handleLinkLocalElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<Session> session);
void unregisterService();
void handleElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<ServerFromClientSession> session);
void handleConnectFinished(boost::shared_ptr<LinkLocalConnector> connector, bool error);
void registerLinkLocalSession(boost::shared_ptr<Session> session);
boost::shared_ptr<Session> getLinkLocalSessionForJID(const JID& jid);
boost::shared_ptr<LinkLocalConnector> getLinkLocalConnectorForJID(const JID& jid);
void handleRosterChanged(boost::shared_ptr<RosterPayload> roster);
void handlePresenceChanged(boost::shared_ptr<Presence> presence);
LinkLocalServiceInfo getLinkLocalServiceInfo(boost::shared_ptr<Presence> presence);
private:
class DummyUserRegistry : public UserRegistry {
public:
DummyUserRegistry() {}
virtual bool isValidUserPassword(const JID&, const String&) const {
return true;
}
};
private:
IDGenerator idGenerator_;
BoostIOServiceThread boostIOServiceThread_;
DummyUserRegistry userRegistry_;
bool dnsSDServiceRegistered_;
bool rosterRequested_;
int clientConnectionPort_;
int linkLocalConnectionPort_;
boost::shared_ptr<DNSSDService> dnsSDService_;
boost::shared_ptr<LinkLocalRoster> linkLocalRoster_;
boost::shared_ptr<BoostConnectionServer> serverFromClientConnectionServer_;
boost::shared_ptr<ServerFromClientSession> serverFromClientSession_;
boost::shared_ptr<BoostConnectionServer> serverFromNetworkConnectionServer_;
std::vector< boost::shared_ptr<SessionTracer> > tracers_;
std::vector< boost::shared_ptr<Session> > linkLocalSessions_;
std::vector< boost::shared_ptr<LinkLocalConnector> > connectors_;
FullPayloadParserFactoryCollection payloadParserFactories_;
FullPayloadSerializerCollection payloadSerializers_;
JID selfJID_;
};
}
|