summaryrefslogtreecommitdiffstats
path: root/Nim
diff options
context:
space:
mode:
Diffstat (limited to 'Nim')
-rw-r--r--Nim/main.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/Nim/main.cpp b/Nim/main.cpp
index 6747d4a..7c7105e 100644
--- a/Nim/main.cpp
+++ b/Nim/main.cpp
@@ -53,14 +53,15 @@ 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->onSessionStarted.connect(boost::bind(&Server::handleSessionStarted, this, session));
session->onSessionFinished.connect(boost::bind(&Server::handleSessionFinished, this, session));
+ session->start();
}
- void handleSessionStarted(ServerFromClientSession* session) {
+ void handleSessionStarted(boost::shared_ptr<ServerFromClientSession> session) {
if (!dnsSDServiceRegistered_) {
dnsSDServiceRegistered_ = true;
dnsSDService_->onServiceRegistered.connect(boost::bind(&Server::handleServiceRegistered, this, _1));
@@ -81,16 +82,15 @@ class Server {
std::cout << "Service registered " << service.name << " " << service.type << " " << service.domain << std::endl;
}
- void handleSessionFinished(ServerFromClientSession* session) {
+ void handleSessionFinished(boost::shared_ptr<ServerFromClientSession> session) {
serverFromClientSessions_.erase(std::remove(serverFromClientSessions_.begin(), serverFromClientSessions_.end(), session), serverFromClientSessions_.end());
- delete session;
if (serverFromClientSessions_.empty()) {
dnsSDServiceRegistered_ = false;
dnsSDService_->unregisterService();
}
}
- 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()));
@@ -124,7 +124,7 @@ class Server {
boost::shared_ptr<AppleDNSSDService> dnsSDService_;
boost::shared_ptr<LinkLocalRoster> linkLocalRoster_;
boost::shared_ptr<BoostConnectionServer> serverFromClientConnectionServer_;
- std::vector<ServerFromClientSession*> serverFromClientSessions_;
+ std::vector< boost::shared_ptr<ServerFromClientSession> > serverFromClientSessions_;
FullPayloadParserFactoryCollection payloadParserFactories_;
FullPayloadSerializerCollection payloadSerializers_;
bool dnsSDServiceRegistered_;