2010-04-15 06:47:48 -04:00
|
|
|
/*
|
|
|
|
* libretroshare/src/services: p3statusservice.cc
|
|
|
|
*
|
|
|
|
* RetroShare C++ .
|
|
|
|
*
|
|
|
|
* Copyright 2008 by Vinny Do, Chris Evi-Parker.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "services/p3statusservice.h"
|
|
|
|
#include "serialiser/rsstatusitems.h"
|
2014-01-07 17:51:22 -05:00
|
|
|
#include "rsserver/p3face.h"
|
2010-08-20 14:45:44 -04:00
|
|
|
#include "retroshare/rsiface.h"
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <map>
|
|
|
|
#include <list>
|
|
|
|
#include <string>
|
2013-10-21 07:00:49 -04:00
|
|
|
#include <time.h>
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2011-07-09 14:39:34 -04:00
|
|
|
#include "pqi/p3linkmgr.h"
|
|
|
|
|
2010-04-15 06:47:48 -04:00
|
|
|
std::ostream& operator<<(std::ostream& out, const StatusInfo& si)
|
|
|
|
{
|
|
|
|
out << "StatusInfo: " << std::endl;
|
|
|
|
out << "id: " << si.id << std::endl;
|
|
|
|
out << "status: " << si.status << std::endl;
|
|
|
|
out << "time_stamp: " << si.time_stamp << std::endl;
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
RsStatus *rsStatus = NULL;
|
|
|
|
|
2014-03-28 23:57:44 -04:00
|
|
|
p3StatusService::p3StatusService(p3ServiceControl *sc)
|
|
|
|
:p3Service(), p3Config(CONFIG_TYPE_STATUS), mServiceCtrl(sc), mStatusMtx("p3StatusService")
|
2010-04-15 06:47:48 -04:00
|
|
|
{
|
|
|
|
addSerialType(new RsStatusSerialiser());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
p3StatusService::~p3StatusService()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-03-21 23:53:44 -04:00
|
|
|
|
|
|
|
const std::string STATUS_APP_NAME = "status";
|
|
|
|
const uint16_t STATUS_APP_MAJOR_VERSION = 1;
|
|
|
|
const uint16_t STATUS_APP_MINOR_VERSION = 0;
|
|
|
|
const uint16_t STATUS_MIN_MAJOR_VERSION = 1;
|
|
|
|
const uint16_t STATUS_MIN_MINOR_VERSION = 0;
|
|
|
|
|
|
|
|
RsServiceInfo p3StatusService::getServiceInfo()
|
|
|
|
{
|
|
|
|
return RsServiceInfo(RS_SERVICE_TYPE_STATUS,
|
|
|
|
STATUS_APP_NAME,
|
|
|
|
STATUS_APP_MAJOR_VERSION,
|
|
|
|
STATUS_APP_MINOR_VERSION,
|
|
|
|
STATUS_MIN_MAJOR_VERSION,
|
|
|
|
STATUS_MIN_MINOR_VERSION);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-20 15:45:07 -04:00
|
|
|
bool p3StatusService::getOwnStatus(StatusInfo& statusInfo)
|
|
|
|
{
|
2010-08-20 14:45:44 -04:00
|
|
|
#ifdef STATUS_DEBUG
|
|
|
|
std::cerr << "p3StatusService::getOwnStatus() " << std::endl;
|
|
|
|
#endif
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsPeerId, StatusInfo>::iterator it;
|
2014-03-28 23:57:44 -04:00
|
|
|
const RsPeerId& ownId = mServiceCtrl->getOwnId();
|
2010-07-20 15:45:07 -04:00
|
|
|
|
|
|
|
RsStackMutex stack(mStatusMtx);
|
|
|
|
it = mStatusInfoMap.find(ownId);
|
|
|
|
|
|
|
|
if (it == mStatusInfoMap.end()){
|
|
|
|
std::cerr << "p3StatusService::saveList() :" << "Did not find your status" << ownId << std::endl;
|
2011-09-08 09:17:49 -04:00
|
|
|
|
|
|
|
// own status not set, set it to online
|
|
|
|
statusInfo.id = ownId;
|
|
|
|
statusInfo.status = RS_STATUS_ONLINE;
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::pair<RsPeerId, StatusInfo> pr(ownId, statusInfo);
|
2011-09-08 09:17:49 -04:00
|
|
|
mStatusInfoMap.insert(pr);
|
|
|
|
IndicateConfigChanged();
|
|
|
|
|
|
|
|
return true;
|
2010-07-20 15:45:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
statusInfo = it->second;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
bool p3StatusService::getStatusList(std::list<StatusInfo>& statusInfo)
|
2010-04-15 06:47:48 -04:00
|
|
|
{
|
|
|
|
#ifdef STATUS_DEBUG
|
2010-08-20 14:45:44 -04:00
|
|
|
std::cerr << "p3StatusService::getStatusList() " << std::endl;
|
2010-04-15 06:47:48 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
statusInfo.clear();
|
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
RsStackMutex stack(mStatusMtx);
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
// fill up statusInfo list with this information
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsPeerId, StatusInfo>::iterator mit;
|
2010-08-20 14:45:44 -04:00
|
|
|
for(mit = mStatusInfoMap.begin(); mit != mStatusInfoMap.end(); mit++){
|
|
|
|
statusInfo.push_back(mit->second);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
bool p3StatusService::getStatus(const RsPeerId &id, StatusInfo &statusInfo)
|
2010-08-20 14:45:44 -04:00
|
|
|
{
|
|
|
|
#ifdef STATUS_DEBUG
|
|
|
|
std::cerr << "p3StatusService::getStatus() " << std::endl;
|
2010-04-15 06:47:48 -04:00
|
|
|
#endif
|
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
RsStackMutex stack(mStatusMtx);
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsPeerId, StatusInfo>::iterator mit = mStatusInfoMap.find(id);
|
2010-08-20 14:45:44 -04:00
|
|
|
|
|
|
|
if (mit == mStatusInfoMap.end()) {
|
|
|
|
/* return fake status info as offline */
|
|
|
|
statusInfo = StatusInfo();
|
2010-04-18 16:01:31 -04:00
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
statusInfo.id = id;
|
|
|
|
statusInfo.status = RS_STATUS_OFFLINE;
|
|
|
|
return false;
|
2010-04-15 06:47:48 -04:00
|
|
|
}
|
2010-08-20 14:45:44 -04:00
|
|
|
|
|
|
|
statusInfo = mit->second;
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-20 15:45:07 -04:00
|
|
|
/* id = "", status is sent to all online peers */
|
2014-03-17 16:56:06 -04:00
|
|
|
bool p3StatusService::sendStatus(const RsPeerId &id, uint32_t status)
|
2010-04-15 06:47:48 -04:00
|
|
|
{
|
2010-07-20 15:45:07 -04:00
|
|
|
StatusInfo statusInfo;
|
2014-03-28 23:57:44 -04:00
|
|
|
std::set<RsPeerId> onlineList;
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
RsStackMutex stack(mStatusMtx);
|
|
|
|
|
2014-03-28 23:57:44 -04:00
|
|
|
statusInfo.id = mServiceCtrl->getOwnId();
|
2010-07-20 15:45:07 -04:00
|
|
|
statusInfo.status = status;
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2010-04-27 07:53:46 -04:00
|
|
|
// don't save inactive status
|
|
|
|
if(statusInfo.status != RS_STATUS_INACTIVE){
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2010-04-27 07:53:46 -04:00
|
|
|
// If your id is not set, set it
|
|
|
|
if(mStatusInfoMap.find(statusInfo.id) == mStatusInfoMap.end()){
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::pair<RsPeerId, StatusInfo> pr(statusInfo.id, statusInfo);
|
2010-04-27 07:53:46 -04:00
|
|
|
mStatusInfoMap.insert(pr);
|
|
|
|
IndicateConfigChanged();
|
2010-07-20 15:45:07 -04:00
|
|
|
} else if(mStatusInfoMap[statusInfo.id].status != statusInfo.status){
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2010-04-27 07:53:46 -04:00
|
|
|
IndicateConfigChanged();
|
|
|
|
mStatusInfoMap[statusInfo.id] = statusInfo;
|
|
|
|
}
|
|
|
|
}
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
if (id.isNull()) {
|
2014-03-28 23:57:44 -04:00
|
|
|
mServiceCtrl->getPeersConnected(getServiceInfo().mServiceType, onlineList);
|
2010-07-20 15:45:07 -04:00
|
|
|
} else {
|
2014-03-28 23:57:44 -04:00
|
|
|
onlineList.insert(id);
|
2010-07-20 15:45:07 -04:00
|
|
|
}
|
2010-04-18 16:01:31 -04:00
|
|
|
}
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2014-03-28 23:57:44 -04:00
|
|
|
std::set<RsPeerId>::iterator it;
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
#ifdef STATUS_DEBUG
|
|
|
|
std::cerr << "p3StatusService::sendStatus() " << std::endl;
|
|
|
|
std::cerr << statusInfo;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// send to all peers online
|
|
|
|
for(it = onlineList.begin(); it != onlineList.end(); it++){
|
|
|
|
RsStatusItem* statusItem = new RsStatusItem();
|
|
|
|
statusItem->sendTime = time(NULL);
|
|
|
|
statusItem->status = statusInfo.status;
|
|
|
|
statusItem->PeerId(*it);
|
|
|
|
sendItem(statusItem);
|
|
|
|
}
|
|
|
|
|
2010-08-30 16:14:58 -04:00
|
|
|
/* send notify of own status change */
|
2014-03-17 16:56:06 -04:00
|
|
|
RsServer::notify()->notifyPeerStatusChanged(statusInfo.id.toStdString(), statusInfo.status);
|
2010-08-30 16:14:58 -04:00
|
|
|
|
2010-04-15 06:47:48 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************/
|
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
void p3StatusService::receiveStatusQueue()
|
2010-06-13 08:26:23 -04:00
|
|
|
{
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsPeerId, uint32_t> changed;
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
{
|
|
|
|
RsStackMutex stack(mStatusMtx);
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
RsItem* item;
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
while(NULL != (item = recvItem())){
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
RsStatusItem* status_item = dynamic_cast<RsStatusItem*>(item);
|
|
|
|
|
|
|
|
if(status_item == NULL) {
|
|
|
|
std::cerr << "p3Status::getStatusQueue() " << "Failed to cast Item \n" << std::endl;
|
|
|
|
delete (item);
|
|
|
|
continue;
|
|
|
|
}
|
2010-06-13 08:26:23 -04:00
|
|
|
|
2010-04-15 06:47:48 -04:00
|
|
|
#ifdef STATUS_DEBUG
|
2010-08-20 14:45:44 -04:00
|
|
|
std::cerr << "p3StatusService::getStatusQueue()" << std::endl;
|
|
|
|
std::cerr << "PeerId : " << status_item->PeerId() << std::endl;
|
|
|
|
std::cerr << "Status: " << status_item->status << std::endl;
|
|
|
|
std::cerr << "Got status Item" << std::endl;
|
2010-04-15 06:47:48 -04:00
|
|
|
#endif
|
2010-08-20 14:45:44 -04:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsPeerId, StatusInfo>::iterator mit = mStatusInfoMap.find(status_item->PeerId());
|
2010-08-20 14:45:44 -04:00
|
|
|
|
|
|
|
if(mit != mStatusInfoMap.end()){
|
|
|
|
mit->second.id = status_item->PeerId();
|
|
|
|
|
|
|
|
if (mit->second.status != status_item->status) {
|
|
|
|
changed [mit->second.id] = status_item->status;
|
|
|
|
}
|
|
|
|
|
|
|
|
mit->second.status = status_item->status;
|
|
|
|
mit->second.time_stamp = status_item->sendTime;
|
|
|
|
#ifdef STATUS_DEBUG
|
|
|
|
} else {
|
|
|
|
std::cerr << "getStatus() " << "Could not find Peer" << status_item->PeerId();
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
delete (status_item);
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* UNLOCKED */
|
|
|
|
|
|
|
|
if (changed.size()) {
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsPeerId, uint32_t>::iterator it;
|
2010-08-20 14:45:44 -04:00
|
|
|
for (it = changed.begin(); it != changed.end(); it++) {
|
2014-03-17 16:56:06 -04:00
|
|
|
RsServer::notify()->notifyPeerStatusChanged(it->first.toStdString(), it->second);
|
2010-08-20 14:45:44 -04:00
|
|
|
}
|
2014-01-07 17:51:22 -05:00
|
|
|
RsServer::notify()->notifyPeerStatusChangedSummary();
|
2010-04-15 06:47:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* p3Config */
|
|
|
|
|
|
|
|
RsSerialiser* p3StatusService::setupSerialiser(){
|
|
|
|
|
|
|
|
RsSerialiser *rss = new RsSerialiser;
|
|
|
|
rss->addSerialType(new RsStatusSerialiser);
|
|
|
|
|
|
|
|
return rss;
|
|
|
|
}
|
|
|
|
|
2010-12-18 14:35:07 -05:00
|
|
|
bool p3StatusService::saveList(bool& cleanup, std::list<RsItem*>& ilist){
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
// save your status before quiting
|
|
|
|
cleanup = true;
|
|
|
|
RsStatusItem* own_status = new RsStatusItem;
|
|
|
|
StatusInfo own_info;
|
2010-12-18 14:35:07 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
std::map<RsPeerId, StatusInfo>::iterator it;
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
RsStackMutex stack(mStatusMtx);
|
2014-03-28 23:57:44 -04:00
|
|
|
it = mStatusInfoMap.find(mServiceCtrl->getOwnId());
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
if(it == mStatusInfoMap.end()){
|
|
|
|
std::cerr << "p3StatusService::saveList() :" << "Did not find your status"
|
2014-03-28 23:57:44 -04:00
|
|
|
<< mServiceCtrl->getOwnId() << std::endl;
|
2010-04-15 06:47:48 -04:00
|
|
|
delete own_status;
|
2010-12-18 14:35:07 -05:00
|
|
|
return false;
|
2010-04-15 06:47:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
own_info = it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
own_status->PeerId(own_info.id);
|
|
|
|
own_status->sendTime = own_info.time_stamp;
|
|
|
|
own_status->status = own_info.status;
|
|
|
|
|
|
|
|
ilist.push_back(own_status);
|
|
|
|
|
2010-12-18 14:35:07 -05:00
|
|
|
return true;
|
2010-04-15 06:47:48 -04:00
|
|
|
}
|
|
|
|
|
2010-12-18 14:35:07 -05:00
|
|
|
bool p3StatusService::loadList(std::list<RsItem*>& load){
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
// load your status from last rs session
|
|
|
|
StatusInfo own_info;
|
2010-04-18 16:01:31 -04:00
|
|
|
std::list<RsItem*>::const_iterator it = load.begin();
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
if(it == load.end()){
|
|
|
|
std::cerr << "p3StatusService::loadList(): Failed to load " << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-04-18 16:01:31 -04:00
|
|
|
for(; it != load.end(); it++){
|
2010-04-15 06:47:48 -04:00
|
|
|
RsStatusItem* own_status = dynamic_cast<RsStatusItem* >(*it);
|
|
|
|
|
|
|
|
|
|
|
|
if(own_status != NULL){
|
|
|
|
|
2014-03-28 23:57:44 -04:00
|
|
|
own_info.id = mServiceCtrl->getOwnId();
|
2010-04-15 06:47:48 -04:00
|
|
|
own_info.status = own_status->status;
|
|
|
|
own_info.time_stamp = own_status->sendTime;
|
2010-04-18 16:01:31 -04:00
|
|
|
delete own_status;
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
RsStackMutex stack(mStatusMtx);
|
2014-03-28 23:57:44 -04:00
|
|
|
std::pair<RsPeerId, StatusInfo> pr(mServiceCtrl->getOwnId(), own_info);
|
2010-04-15 06:47:48 -04:00
|
|
|
mStatusInfoMap.insert(pr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
std::cerr << "p3StatusService::loadList " << "Failed to load list "
|
|
|
|
<< std::endl;
|
|
|
|
}
|
|
|
|
|
2010-04-18 16:01:31 -04:00
|
|
|
}
|
2010-04-15 06:47:48 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
int p3StatusService::tick()
|
|
|
|
{
|
|
|
|
if (receivedItems()) {
|
|
|
|
receiveStatusQueue();
|
|
|
|
}
|
|
|
|
|
2010-04-15 06:47:48 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int p3StatusService::status(){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-07-20 15:45:07 -04:00
|
|
|
/*************** pqiMonitor callback ***********************/
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2014-03-28 23:57:44 -04:00
|
|
|
void p3StatusService::statusChange(const std::list<pqiServicePeer> &plist)
|
2010-07-20 15:45:07 -04:00
|
|
|
{
|
2010-08-20 14:45:44 -04:00
|
|
|
bool changedState = false;
|
|
|
|
|
2010-07-20 15:45:07 -04:00
|
|
|
StatusInfo statusInfo;
|
2014-03-28 23:57:44 -04:00
|
|
|
std::list<pqiServicePeer>::const_iterator it;
|
|
|
|
for (it = plist.begin(); it != plist.end(); it++)
|
|
|
|
{
|
|
|
|
if (it->actions & RS_SERVICE_PEER_DISCONNECTED)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RsStackMutex stack(mStatusMtx);
|
|
|
|
/* remove peer from status map */
|
|
|
|
mStatusInfoMap.erase(it->id);
|
|
|
|
} /* UNLOCKED */
|
|
|
|
|
|
|
|
changedState = true;
|
|
|
|
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_OFFLINE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (it->actions & RS_SERVICE_PEER_CONNECTED)
|
|
|
|
{
|
|
|
|
/* send current status, only call getOwnStatus once in the loop */
|
|
|
|
if (statusInfo.id.isNull() == false || getOwnStatus(statusInfo))
|
2010-08-20 14:45:44 -04:00
|
|
|
{
|
2014-03-28 23:57:44 -04:00
|
|
|
sendStatus(it->id, statusInfo.status);
|
2010-08-20 14:45:44 -04:00
|
|
|
}
|
|
|
|
|
2014-03-28 23:57:44 -04:00
|
|
|
{
|
|
|
|
RsStackMutex stack(mStatusMtx);
|
2010-08-20 14:45:44 -04:00
|
|
|
|
2014-03-28 23:57:44 -04:00
|
|
|
/* We assume that the peer is online. If not, he send us a new status */
|
|
|
|
StatusInfo info;
|
|
|
|
info.id = it->id;
|
|
|
|
info.status = RS_STATUS_ONLINE;
|
|
|
|
info.time_stamp = time(NULL);
|
2010-08-20 14:45:44 -04:00
|
|
|
|
2014-03-28 23:57:44 -04:00
|
|
|
mStatusInfoMap[it->id] = info;
|
|
|
|
} /* UNLOCKED */
|
2010-08-20 14:45:44 -04:00
|
|
|
|
2014-03-28 23:57:44 -04:00
|
|
|
changedState = true;
|
|
|
|
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_ONLINE);
|
|
|
|
}
|
2010-08-20 14:45:44 -04:00
|
|
|
|
2014-03-28 23:57:44 -04:00
|
|
|
if (it->actions & RS_SERVICE_PEER_REMOVED)
|
|
|
|
{
|
2012-02-24 20:48:56 -05:00
|
|
|
/* now handle remove */
|
|
|
|
{
|
|
|
|
RsStackMutex stack(mStatusMtx);
|
|
|
|
/* remove peer from status map */
|
|
|
|
mStatusInfoMap.erase(it->id);
|
|
|
|
} /* UNLOCKED */
|
|
|
|
|
|
|
|
changedState = true;
|
2014-03-17 16:56:06 -04:00
|
|
|
RsServer::notify()->notifyPeerStatusChanged(it->id.toStdString(), RS_STATUS_OFFLINE);
|
2010-07-20 15:45:07 -04:00
|
|
|
}
|
|
|
|
}
|
2010-08-20 14:45:44 -04:00
|
|
|
|
|
|
|
if (changedState)
|
|
|
|
{
|
2014-01-07 17:51:22 -05:00
|
|
|
RsServer::notify()->notifyPeerStatusChangedSummary();
|
2010-08-20 14:45:44 -04:00
|
|
|
}
|
2010-07-20 15:45:07 -04:00
|
|
|
}
|