summaryrefslogtreecommitdiffstats
path: root/Limber
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-17 19:15:54 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-17 19:15:54 (GMT)
commita328466bc492c50c443e406b9325542a75182327 (patch)
tree8388cb92845a20d5c495e5940f5f16a6b95363a3 /Limber
parent436ae921afbc5c2b461ee9b2d8fa9b1c869ed274 (diff)
downloadswift-a328466bc492c50c443e406b9325542a75182327.zip
swift-a328466bc492c50c443e406b9325542a75182327.tar.bz2
Implemented clean session/connection shutdown.
Diffstat (limited to 'Limber')
-rw-r--r--Limber/main.cpp10
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_;
};