diff options
| author | Remko Tronçon <git@el-tramo.be> | 2011-10-07 18:09:30 (GMT) |
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2011-10-07 18:09:30 (GMT) |
| commit | 6b98253a4127c975bd59b6a49ddb203337a8c32b (patch) | |
| tree | 546a24e1687f50e403215152d65e21971568f166 /Slimber/Server.cpp | |
| parent | b2f58c4f3eb93e3a32062670df5eb6682aed273a (diff) | |
| download | swift-contrib-6b98253a4127c975bd59b6a49ddb203337a8c32b.zip swift-contrib-6b98253a4127c975bd59b6a49ddb203337a8c32b.tar.bz2 | |
Hoist XML parser factory creation out of Swiften.
Diffstat (limited to 'Slimber/Server.cpp')
| -rw-r--r-- | Slimber/Server.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp index 84b33fa..769217f 100644 --- a/Slimber/Server.cpp +++ b/Slimber/Server.cpp @@ -115,71 +115,71 @@ void Server::stop(boost::optional<ServerError> e) { } linkLocalSessions.clear(); foreach(boost::shared_ptr<LinkLocalConnector> connector, connectors) { connector->cancel(); } connectors.clear(); tracers.clear(); if (serverFromNetworkConnectionServer) { serverFromNetworkConnectionServer->stop(); foreach(boost::bsignals::connection& connection, serverFromNetworkConnectionServerSignalConnections) { connection.disconnect(); } serverFromNetworkConnectionServerSignalConnections.clear(); serverFromNetworkConnectionServer.reset(); } if (serverFromClientConnectionServer) { serverFromClientConnectionServer->stop(); foreach(boost::bsignals::connection& connection, serverFromClientConnectionServerSignalConnections) { connection.disconnect(); } serverFromClientConnectionServerSignalConnections.clear(); serverFromClientConnectionServer.reset(); } stopping = false; onStopped(e); } void Server::handleNewClientConnection(boost::shared_ptr<Connection> connection) { if (serverFromClientSession) { connection->disconnect(); } serverFromClientSession = boost::shared_ptr<ServerFromClientSession>( new ServerFromClientSession(idGenerator.generateID(), connection, - &payloadParserFactories, &payloadSerializers, &userRegistry)); + &payloadParserFactories, &payloadSerializers, &xmlParserFactory, &userRegistry)); serverFromClientSession->setAllowSASLEXTERNAL(); serverFromClientSession->onSessionStarted.connect( boost::bind(&Server::handleSessionStarted, this)); serverFromClientSession->onElementReceived.connect( boost::bind(&Server::handleElementReceived, this, _1, serverFromClientSession)); serverFromClientSession->onSessionFinished.connect( boost::bind(&Server::handleSessionFinished, this, serverFromClientSession)); //tracers.push_back(boost::shared_ptr<SessionTracer>( // new SessionTracer(serverFromClientSession))); serverFromClientSession->startSession(); } void Server::handleSessionStarted() { onSelfConnected(true); } void Server::handleSessionFinished(boost::shared_ptr<ServerFromClientSession>) { serverFromClientSession.reset(); unregisterService(); selfJID = JID(); rosterRequested = false; onSelfConnected(false); lastPresence.reset(); } void Server::unregisterService() { if (linkLocalServiceRegistered) { linkLocalServiceRegistered = false; linkLocalServiceBrowser->unregisterService(); } } void Server::handleElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<ServerFromClientSession> session) { @@ -249,102 +249,102 @@ void Server::handleElementReceived(boost::shared_ptr<Element> element, boost::sh if (outgoingSession) { outgoingSession->sendElement(stanza); } else { boost::optional<LinkLocalService> service = presenceManager->getServiceForJID(toJID); if (service) { boost::shared_ptr<LinkLocalConnector> connector = getLinkLocalConnectorForJID(toJID); if (!connector) { connector = boost::shared_ptr<LinkLocalConnector>( new LinkLocalConnector( *service, linkLocalServiceBrowser->getQuerier(), BoostConnection::create(boostIOServiceThread.getIOService(), eventLoop))); connector->onConnectFinished.connect( boost::bind(&Server::handleConnectFinished, this, connector, _1)); connectors.push_back(connector); connector->connect(); } connector->queueElement(element); } else { session->sendElement(IQ::createError( stanza->getFrom(), stanza->getID(), ErrorPayload::RecipientUnavailable, ErrorPayload::Wait)); } } } } void Server::handleNewLinkLocalConnection(boost::shared_ptr<Connection> connection) { boost::shared_ptr<IncomingLinkLocalSession> session( new IncomingLinkLocalSession( selfJID, connection, - &payloadParserFactories, &payloadSerializers)); + &payloadParserFactories, &payloadSerializers, &xmlParserFactory)); registerLinkLocalSession(session); } void Server::handleLinkLocalSessionFinished(boost::shared_ptr<Session> session) { //std::cout << "Link local session from " << session->getRemoteJID() << " ended" << std::endl; linkLocalSessions.erase( std::remove(linkLocalSessions.begin(), linkLocalSessions.end(), session), linkLocalSessions.end()); } void Server::handleLinkLocalElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<Session> session) { if (boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(element)) { JID fromJID = session->getRemoteJID(); if (!presenceManager->getServiceForJID(fromJID.toBare())) { return; // TODO: Send error back } stanza->setFrom(fromJID); serverFromClientSession->sendElement(stanza); } } void Server::handleConnectFinished(boost::shared_ptr<LinkLocalConnector> connector, bool error) { if (error) { std::cerr << "Error connecting" << std::endl; // TODO: Send back queued stanzas } else { boost::shared_ptr<OutgoingLinkLocalSession> outgoingSession( new OutgoingLinkLocalSession( selfJID, connector->getService().getJID(), connector->getConnection(), - &payloadParserFactories, &payloadSerializers)); + &payloadParserFactories, &payloadSerializers, &xmlParserFactory)); foreach(const boost::shared_ptr<Element> element, connector->getQueuedElements()) { outgoingSession->queueElement(element); } registerLinkLocalSession(outgoingSession); } connectors.erase(std::remove(connectors.begin(), connectors.end(), connector), connectors.end()); } void Server::registerLinkLocalSession(boost::shared_ptr<Session> session) { session->onSessionFinished.connect( boost::bind(&Server::handleLinkLocalSessionFinished, this, session)); session->onElementReceived.connect( boost::bind(&Server::handleLinkLocalElementReceived, this, _1, session)); linkLocalSessions.push_back(session); //tracers.push_back(boost::shared_ptr<SessionTracer>(new SessionTracer(session))); session->startSession(); } boost::shared_ptr<Session> Server::getLinkLocalSessionForJID(const JID& jid) { foreach(const boost::shared_ptr<Session> session, linkLocalSessions) { if (session->getRemoteJID() == jid) { return session; } } return boost::shared_ptr<Session>(); } boost::shared_ptr<LinkLocalConnector> Server::getLinkLocalConnectorForJID(const JID& jid) { foreach(const boost::shared_ptr<LinkLocalConnector> connector, connectors) { if (connector->getService().getJID() == jid) { return connector; } } return boost::shared_ptr<LinkLocalConnector>(); } |
Swift