diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-07-17 19:15:54 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-07-17 19:15:54 (GMT) |
commit | a328466bc492c50c443e406b9325542a75182327 (patch) | |
tree | 8388cb92845a20d5c495e5940f5f16a6b95363a3 /Limber/main.cpp | |
parent | 436ae921afbc5c2b461ee9b2d8fa9b1c869ed274 (diff) | |
download | swift-contrib-a328466bc492c50c443e406b9325542a75182327.zip swift-contrib-a328466bc492c50c443e406b9325542a75182327.tar.bz2 |
Implemented clean session/connection shutdown.
Diffstat (limited to 'Limber/main.cpp')
-rw-r--r-- | Limber/main.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Limber/main.cpp b/Limber/main.cpp index c478924..2a2197d 100644 --- a/Limber/main.cpp +++ b/Limber/main.cpp @@ -31,18 +31,18 @@ class Server { private: void handleNewConnection(boost::shared_ptr<Connection> c) { - ServerFromClientSession* session = new ServerFromClientSession(idGenerator_.generateID(), c, &payloadParserFactories_, &payloadSerializers_, userRegistry_); + boost::shared_ptr<ServerFromClientSession> session(new ServerFromClientSession(idGenerator_.generateID(), c, &payloadParserFactories_, &payloadSerializers_, userRegistry_)); serverFromClientSessions_.push_back(session); session->onStanzaReceived.connect(boost::bind(&Server::handleStanzaReceived, this, _1, session)); session->onSessionFinished.connect(boost::bind(&Server::handleSessionFinished, this, session)); + session->start(); } - void handleSessionFinished(ServerFromClientSession* session) { + void handleSessionFinished(boost::shared_ptr<ServerFromClientSession> session) { serverFromClientSessions_.erase(std::remove(serverFromClientSessions_.begin(), serverFromClientSessions_.end(), session), serverFromClientSessions_.end()); - delete session; } - void handleStanzaReceived(boost::shared_ptr<Stanza> stanza, ServerFromClientSession* session) { + void handleStanzaReceived(boost::shared_ptr<Stanza> stanza, boost::shared_ptr<ServerFromClientSession> session) { stanza->setFrom(session->getJID()); if (!stanza->getTo().isValid()) { stanza->setTo(JID(session->getDomain())); @@ -74,7 +74,7 @@ class Server { UserRegistry* userRegistry_; BoostIOServiceThread boostIOServiceThread_; boost::shared_ptr<BoostConnectionServer> serverFromClientConnectionServer_; - std::vector<ServerFromClientSession*> serverFromClientSessions_; + std::vector< boost::shared_ptr<ServerFromClientSession> > serverFromClientSessions_; FullPayloadParserFactoryCollection payloadParserFactories_; FullPayloadSerializerCollection payloadSerializers_; }; |