diff options
author | Remko Tronçon <git@el-tramo.be> | 2012-03-20 19:22:52 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2012-03-20 19:22:52 (GMT) |
commit | 8680839b69f431d293c17863e56db8963e4ade74 (patch) | |
tree | 49ade7f0f073b76c8e009af711e954acab1b741f | |
parent | 3d6694b0c698fff63d11f8bb4aa995c1df882315 (diff) | |
download | swift-contrib-8680839b69f431d293c17863e56db8963e4ade74.zip swift-contrib-8680839b69f431d293c17863e56db8963e4ade74.tar.bz2 |
Fix for the previous patch.
-rw-r--r-- | Limber/main.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Limber/main.cpp b/Limber/main.cpp index 3db3092..3809729 100644 --- a/Limber/main.cpp +++ b/Limber/main.cpp @@ -29,71 +29,71 @@ using namespace Swift; class Server { public: Server(UserRegistry* userRegistry, EventLoop* eventLoop) : userRegistry_(userRegistry) { serverFromClientConnectionServer_ = BoostConnectionServer::create(5222, boostIOServiceThread_.getIOService(), eventLoop); serverFromClientConnectionServer_->onNewConnection.connect(boost::bind(&Server::handleNewConnection, this, _1)); serverFromClientConnectionServer_->start(); } private: void handleNewConnection(boost::shared_ptr<Connection> c) { boost::shared_ptr<ServerFromClientSession> session(new ServerFromClientSession(idGenerator_.generateID(), c, &payloadParserFactories_, &payloadSerializers_, &xmlParserFactory, userRegistry_)); serverFromClientSessions_.push_back(session); session->onElementReceived.connect(boost::bind(&Server::handleElementReceived, this, _1, session)); session->onSessionFinished.connect(boost::bind(&Server::handleSessionFinished, this, session)); session->startSession(); } void handleSessionFinished(boost::shared_ptr<ServerFromClientSession> session) { serverFromClientSessions_.erase(std::remove(serverFromClientSessions_.begin(), serverFromClientSessions_.end(), session), serverFromClientSessions_.end()); } void handleElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<ServerFromClientSession> session) { boost::shared_ptr<Stanza> stanza(boost::dynamic_pointer_cast<Stanza>(element)); if (!stanza) { return; } stanza->setFrom(session->getRemoteJID()); if (!stanza->getTo().isValid()) { stanza->setTo(JID(session->getLocalJID())); } if (!stanza->getTo().isValid() || stanza->getTo() == session->getLocalJID() || stanza->getTo() == session->getRemoteJID().toBare()) { if (boost::shared_ptr<IQ> iq = boost::dynamic_pointer_cast<IQ>(stanza)) { if (iq->getPayload<RosterPayload>()) { - session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), boost::make_shared<RosterPayload>()))); + session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), boost::make_shared<RosterPayload>())); } if (iq->getPayload<VCard>()) { if (iq->getType() == IQ::Get) { boost::shared_ptr<VCard> vcard(new VCard()); vcard->setNickname(iq->getFrom().getNode()); session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), vcard)); } else { session->sendElement(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::Forbidden, ErrorPayload::Cancel)); } } else { session->sendElement(IQ::createError(iq->getFrom(), iq->getID(), ErrorPayload::FeatureNotImplemented, ErrorPayload::Cancel)); } } } } private: IDGenerator idGenerator_; PlatformXMLParserFactory xmlParserFactory; UserRegistry* userRegistry_; BoostIOServiceThread boostIOServiceThread_; boost::shared_ptr<BoostConnectionServer> serverFromClientConnectionServer_; std::vector< boost::shared_ptr<ServerFromClientSession> > serverFromClientSessions_; FullPayloadParserFactoryCollection payloadParserFactories_; FullPayloadSerializerCollection payloadSerializers_; }; int main() { SimpleEventLoop eventLoop; SimpleUserRegistry userRegistry; userRegistry.addUser(JID("remko@localhost"), "remko"); userRegistry.addUser(JID("kevin@localhost"), "kevin"); userRegistry.addUser(JID("remko@limber.swift.im"), "remko"); |