Files
@ a6cee4572298
Branch filter:
Location: libtransport.git/libtransport/UsersReconnecter.cpp - annotation
a6cee4572298
2.5 KiB
text/x-c++hdr
Dockerfile.stretch: add missing tools
56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 78e71f9345c7 78e71f9345c7 78e71f9345c7 78e71f9345c7 78e71f9345c7 5adb3d1f9733 56dd64999814 56dd64999814 56dd64999814 cc64a76c8be5 cc64a76c8be5 56dd64999814 56dd64999814 56dd64999814 56dd64999814 7c93aee6f49a 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 6d2f8c192761 56dd64999814 56dd64999814 56dd64999814 6d2f8c192761 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 fe47e0979be9 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 5adb3d1f9733 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 56dd64999814 | /**
* XMPP - libpurple transport
*
* Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include "transport/UsersReconnecter.h"
#include "transport/StorageBackend.h"
#include "transport/Transport.h"
#include "transport/Logging.h"
#include "transport/Frontend.h"
#include "transport/Config.h"
#include <iostream>
#include <boost/bind.hpp>
#include "Swiften/Network/NetworkFactories.h"
using namespace Swift;
namespace Transport {
DEFINE_LOGGER(logger, "UserReconnecter");
UsersReconnecter::UsersReconnecter(Component *component, StorageBackend *storageBackend) {
m_component = component;
m_storageBackend = storageBackend;
m_started = false;
m_nextUserTimer = m_component->getNetworkFactories()->getTimerFactory()->createTimer(1000);
m_nextUserTimer->onTick.connect(boost::bind(&UsersReconnecter::reconnectNextUser, this));
m_component->onConnected.connect(boost::bind(&UsersReconnecter::handleConnected, this));
}
UsersReconnecter::~UsersReconnecter() {
m_component->onConnected.disconnect(boost::bind(&UsersReconnecter::handleConnected, this));
m_nextUserTimer->stop();
m_nextUserTimer->onTick.disconnect(boost::bind(&UsersReconnecter::reconnectNextUser, this));
}
void UsersReconnecter::reconnectNextUser() {
if (m_users.empty()) {
LOG4CXX_INFO(logger, "All users reconnected, stopping UserReconnecter.");
return;
}
std::string user = m_users.back();
m_users.pop_back();
m_component->getFrontend()->reconnectUser(user);
m_nextUserTimer->start();
}
void UsersReconnecter::handleConnected() {
if (m_started)
return;
LOG4CXX_INFO(logger, "Starting UserReconnecter.");
m_started = true;
if (CONFIG_BOOL_DEFAULTED(m_component->getConfig(), "service.reconnect_all_users", false)) {
m_storageBackend->getUsers(m_users);
}
else {
m_storageBackend->getOnlineUsers(m_users);
}
reconnectNextUser();
}
}
|