Merge pull request #1847 from csoler/v0.6-GxsDbFix

This branch aims at fixing the requests problems in RsGxsDataAccess
This commit is contained in:
csoler 2020-04-13 14:13:33 +02:00 committed by GitHub
commit b6c5e2f188
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 1059 additions and 774 deletions

View file

@ -26,10 +26,6 @@
* #define RS_DATA_SERVICE_DEBUG_CACHE 1
****/
#define RS_DATA_SERVICE_DEBUG 1
#define RS_DATA_SERVICE_DEBUG_TIME 1
#define RS_DATA_SERVICE_DEBUG_CACHE 1
#include <fstream>
#include <util/rsdir.h>
#include <algorithm>

View file

@ -1193,7 +1193,7 @@ bool RsGenExchange::getGroupList(const uint32_t &token, std::list<RsGxsGroupId>
bool RsGenExchange::getMsgList(const uint32_t &token,
GxsMsgIdResult &msgIds)
{
return mDataAccess->getMsgList(token, msgIds);
return mDataAccess->getMsgIdList(token, msgIds);
}
bool RsGenExchange::getMsgRelatedList(const uint32_t &token, MsgRelatedIdResult &msgIds)
@ -1692,7 +1692,7 @@ void RsGenExchange::notifyChangedGroupStats(const RsGxsGroupId &grpId)
{
RS_STACK_MUTEX(mGenMtx);
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_PROCESSED, false);
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_STATISTICS_CHANGED, false);
gc->mGrpIdList.push_back(grpId);
mNotifications.push_back(gc);
}

File diff suppressed because it is too large Load diff

View file

@ -22,6 +22,7 @@
#ifndef RSGXSDATAACCESS_H
#define RSGXSDATAACCESS_H
#include <queue>
#include "retroshare/rstokenservice.h"
#include "rsgxsrequesttypes.h"
#include "rsgds.h"
@ -30,6 +31,8 @@
typedef std::map< RsGxsGroupId, std::map<RsGxsMessageId, RsGxsMsgMetaData*> > MsgMetaFilter;
typedef std::map< RsGxsGroupId, RsGxsGrpMetaData* > GrpMetaFilter;
bool operator<(const std::pair<uint32_t,GxsRequest*>& p1,const std::pair<uint32_t,GxsRequest*>& p2);
class RsGxsDataAccess : public RsTokenService
{
public:
@ -56,7 +59,7 @@ public:
* @param groupIds group id to request info for
* @return
*/
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds);
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId> &groupIds) override;
/*!
* Use this to request all group related info
@ -65,7 +68,7 @@ public:
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
* @return
*/
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts);
bool requestGroupInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts) override;
/*!
* Use this to get msg information (id, meta, or data), store token value to poll for request completion
@ -75,7 +78,7 @@ public:
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq& msgIds);
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const GxsMsgReq& msgIds) override;
/*!
* Use this to get message information (id, meta, or data), store token value to poll for request completion
@ -86,7 +89,7 @@ public:
* all messages for all groups are retrieved
* @return true if request successful false otherwise
*/
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds);
bool requestMsgInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<RsGxsGroupId>& grpIds) override;
/*!
* For requesting msgs related to a given msg id within a group
@ -96,7 +99,7 @@ public:
* @param groupIds The ids of the groups to get, second entry of map empty to query for all msgs
* @return true if request successful false otherwise
*/
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgIds);
bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair> &msgIds) override;
/*!
* This request statistics on amount of data held
@ -107,19 +110,20 @@ public:
* total size of messages
* total size of groups
* @param token
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
*/
void requestServiceStatistic(uint32_t& token);
void requestServiceStatistic(uint32_t& token, const RsTokReqOptions &opts) override;
/*!
* To request statistic on a group
* @param token set to value to be redeemed to get statistic
* @param grpId the id of the group
* @param opts Additional option that affect outcome of request. Please see specific services, for valid values
*/
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId);
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId, const RsTokReqOptions &opts) override;
/* Poll */
GxsRequestStatus requestStatus(const uint32_t token);
GxsRequestStatus requestStatus(uint32_t token);
/* Cancel Request */
bool cancelRequest(const uint32_t &token);
@ -200,7 +204,8 @@ public:
* @param token request token to be redeemed
* @param msgIds
*/
bool getMsgList(const uint32_t &token, GxsMsgIdResult &msgIds);
bool getMsgIdList(const uint32_t &token, GxsMsgIdResult &msgIds);
/*!
* Retrieve msg list for a given token for message related info
@ -271,7 +276,7 @@ private:
* @param token the value of the token for the request object handle wanted
* @return the request associated to this token
*/
GxsRequest* locked_retrieveRequest(const uint32_t& token);
GxsRequest* locked_retrieveCompetedRequest(const uint32_t& token);
/*!
* Add a gxs request to queue
@ -378,8 +383,18 @@ private:
* @param req
* @return false if unsuccessful, true otherwise
*/
bool getMsgList(MsgIdReq* req);
bool getMsgIdList(MsgIdReq* req);
/*!
* Attempts to retrieve msg Meta list from data store
* Computationally/CPU-Bandwidth expensive
*
* @param msgIds List of message Ids for the Message Metas to retrieve
* @param opts GxsRequest options
* @param result Map of Meta information for messages
*
*/
bool getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgMetaResult& result );
/*!
* Attempts to retrieve group meta data from data store
@ -445,7 +460,7 @@ private:
* @param opts the request options set by user
* @param meta The accompanying meta information for msg, ids
*/
void filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOptions& opts, const MsgMetaFilter& meta) const;
void filterMsgIdList(GxsMsgIdResult& msgIds, const RsTokReqOptions& opts, const MsgMetaFilter& meta) const;
/*!
* This filter msgs based of options supplied (at the moment just status masks)
@ -482,9 +497,10 @@ private:
* @param opts the options used to parameterise the id filter
* @param msgIdsOut the left overs ids after filter is applied to msgIds
*/
bool getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgReq& msgIdsOut);
bool getMsgIdList(const GxsMsgReq& msgIds, const RsTokReqOptions& opts, GxsMsgReq& msgIdsOut);
private:
bool locked_clearRequest(const uint32_t &token);
RsGeneralDataService* mDataStore;
@ -492,10 +508,9 @@ private:
uint32_t mNextToken;
std::map<uint32_t, GxsRequestStatus> mPublicToken;
std::map<uint32_t, GxsRequest*> mRequests;
std::set<std::pair<uint32_t,GxsRequest*> > mRequestQueue;
std::map<uint32_t, GxsRequest*> mCompletedRequests;
};
#endif // RSGXSDATAACCESS_H

View file

@ -23,6 +23,128 @@
#include "rsgxsrequesttypes.h"
#include "util/rsstd.h"
std::ostream& operator<<(std::ostream& o,const GxsRequest& g)
{
return g.print(o);
}
std::ostream& GroupMetaReq::print(std::ostream& o) const
{
o << "[Request type=GroupMeta groupIds (size=" << mGroupIds.size() << "): " ;
if(!mGroupIds.empty())
{
o << *mGroupIds.begin() ;
if(mGroupIds.size() > 1)
o << " ..." ;
}
o << "]" ;
return o;
}
std::ostream& GroupIdReq::print(std::ostream& o) const
{
return o << "[Request type=GroupIdReq" << "]" ;
}
std::ostream& GroupSerializedDataReq::print(std::ostream& o) const
{
return o << "[Request type=GroupSerializedData" << "]" ;
}
std::ostream& GroupDataReq::print(std::ostream& o) const
{
o << "[Request type=GroupDataReq groupIds (size=" << mGroupIds.size() << "): " ;
if(!mGroupIds.empty())
{
o << *mGroupIds.begin() ;
if(mGroupIds.size() > 1)
o << " ..." ;
}
o << "]" ;
return o;
}
std::ostream& MsgIdReq::print(std::ostream& o) const
{
return o << "[Request type=MsgId" << "]" ;
}
std::ostream& MsgMetaReq::print(std::ostream& o) const
{
o << "[Request type=MsgMetaReq groups (size=" << mMsgIds.size() << "): " ;
if(!mMsgIds.empty())
{
o << mMsgIds.begin()->first << " (" << mMsgIds.begin()->second.size() << " messages)";
if(mMsgIds.size() > 1)
o << " ..." ;
}
o << "]" ;
return o;
}
std::ostream& MsgDataReq::print(std::ostream& o) const
{
o << "[Request type=MsgDataReq groups (size=" << mMsgIds.size() << "): " ;
if(!mMsgIds.empty())
{
o << mMsgIds.begin()->first << " (" << mMsgIds.begin()->second.size() << " messages)";
if(mMsgIds.size() > 1)
o << " ..." ;
}
o << "]" ;
return o;
}
std::ostream& MsgRelatedInfoReq::print(std::ostream& o) const
{
o << "[Request type=MsgRelatedInfo msgIds (size=" << mMsgIds.size() << "): " ;
if(!mMsgIds.empty())
{
o << mMsgIds.begin()->first ;
if(mMsgIds.size() > 1)
o << " ..." ;
}
o << "]" ;
return o;
}
std::ostream& GroupSetFlagReq::print(std::ostream& o) const
{
return o << "[Request type=GroupFlagSet grpId=" << grpId << "]" ;
}
std::ostream& ServiceStatisticRequest::print(std::ostream& o) const
{
return o << "[Request type=ServiceStatistics" << "]" ;
}
std::ostream& GroupStatisticRequest::print(std::ostream& o) const
{
return o << "[Request type=GroupStatistics grpId=" << mGrpId << "]" ;
}
GroupMetaReq::~GroupMetaReq()
{
//rsstd::delete_all(mGroupMetaData.begin(), mGroupMetaData.end()); // now memory ownership is kept by the cache.
@ -57,3 +179,8 @@ MsgRelatedInfoReq::~MsgRelatedInfoReq()
rsstd::delete_all(dataIt->second.begin(), dataIt->second.end());
}
}
std::ostream& MessageSetFlagReq::print(std::ostream& o) const
{
return o << "[Request type=MsgFlagSet" << "]" ;
}

View file

@ -29,25 +29,30 @@
struct GxsRequest
{
GxsRequest() :
token(0), reqTime(0), ansType(0), reqType(0),
token(0), reqTime(0), clientAnswerType(0), reqType(0),
status(RsTokenService::FAILED) {}
virtual ~GxsRequest() {}
uint32_t token;
uint32_t reqTime;
RS_DEPRECATED uint32_t ansType; /// G10h4ck: This is of no use
uint32_t clientAnswerType; /// This is made available to the clients in order to keep track of why specific requests where sent..
uint32_t reqType;
RsTokReqOptions Options;
RsTokenService::GxsRequestStatus status;
virtual std::ostream& print(std::ostream& o) const = 0;
};
std::ostream& operator<<(std::ostream& o,const GxsRequest& g);
class GroupMetaReq : public GxsRequest
{
public:
virtual ~GroupMetaReq();
virtual std::ostream& print(std::ostream& o) const override;
public:
std::list<RsGxsGroupId> mGroupIds;
std::list<const RsGxsGrpMetaData*> mGroupMetaData;
@ -56,12 +61,16 @@ public:
class GroupIdReq : public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
std::list<RsGxsGroupId> mGroupIds;
std::list<RsGxsGroupId> mGroupIdResult;
};
class GroupSerializedDataReq : public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
std::list<RsGxsGroupId> mGroupIds;
std::list<RsNxsGrp*> mGroupData;
};
@ -71,6 +80,7 @@ class GroupDataReq : public GxsRequest
public:
virtual ~GroupDataReq();
virtual std::ostream& print(std::ostream& o) const override;
public:
std::list<RsGxsGroupId> mGroupIds;
std::list<RsNxsGrp*> mGroupData;
@ -79,6 +89,8 @@ public:
class MsgIdReq : public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
GxsMsgReq mMsgIds;
GxsMsgIdResult mMsgIdResult;
};
@ -88,6 +100,8 @@ class MsgMetaReq : public GxsRequest
public:
virtual ~MsgMetaReq();
virtual std::ostream& print(std::ostream& o) const override;
public:
GxsMsgReq mMsgIds;
GxsMsgMetaResult mMsgMetaData;
@ -98,6 +112,7 @@ class MsgDataReq : public GxsRequest
public:
virtual ~MsgDataReq();
virtual std::ostream& print(std::ostream& o) const override;
public:
GxsMsgReq mMsgIds;
NxsMsgDataResult mMsgData;
@ -106,12 +121,15 @@ public:
class ServiceStatisticRequest: public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
GxsServiceStatistic mServiceStatistic;
};
struct GroupStatisticRequest: public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
RsGxsGroupId mGrpId;
GxsGroupStatistic mGroupStatistic;
};
@ -121,6 +139,7 @@ class MsgRelatedInfoReq : public GxsRequest
public:
virtual ~MsgRelatedInfoReq();
std::ostream& print(std::ostream& o) const override;
public:
std::vector<RsGxsGrpMsgIdPair> mMsgIds;
MsgRelatedIdResult mMsgIdResult;
@ -131,6 +150,8 @@ public:
class GroupSetFlagReq : public GxsRequest
{
public:
virtual std::ostream& print(std::ostream& o) const override ;
const static uint32_t FLAG_SUBSCRIBE;
const static uint32_t FLAG_STATUS;
@ -145,6 +166,7 @@ class MessageSetFlagReq : public GxsRequest
public:
const static uint32_t FLAG_STATUS;
virtual std::ostream& print(std::ostream& o) const override ;
uint8_t type;
uint32_t flag;
uint32_t flagMask;

View file

@ -111,6 +111,7 @@ enum class RsChannelEventCode: uint8_t
SUBSCRIBE_STATUS_CHANGED = 0x06, // subscription for channel mChannelGroupId changed.
READ_STATUS_CHANGED = 0x07, // existing message has been read or set to unread
RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id
STATISTICS_CHANGED = 0x09, // stats (nb of supplier friends, how many msgs they have etc) has changed
};
struct RsGxsChannelEvent: RsEvent

View file

@ -111,6 +111,7 @@ enum class RsForumEventCode: uint8_t
UPDATED_MESSAGE = 0x04, /// existing message has been updated in a particular forum
SUBSCRIBE_STATUS_CHANGED = 0x05, /// forum was subscribed or unsubscribed
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
STATISTICS_CHANGED = 0x07, /// suppliers and how many messages they have changed
};
struct RsGxsForumEvent: RsEvent

View file

@ -40,7 +40,9 @@
* are necessary, so at this point this workaround seems acceptable.
*/
#define DEBUG_GXSIFACEHELPER 1
//==================================
// #define DEBUG_GXSIFACEHELPER 1
//==================================
enum class TokenRequestType: uint8_t
{
@ -267,7 +269,9 @@ public:
{
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
else
@ -295,7 +299,9 @@ public:
{
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
else
@ -310,7 +316,9 @@ public:
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]= (msgIds.size()==1 && msgIds.begin()->second.size()==0) ?(TokenRequestType::ALL_POSTS):(TokenRequestType::POSTS);
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
else
@ -324,7 +332,9 @@ public:
{
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::ALL_POSTS;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
else
@ -340,7 +350,9 @@ public:
{
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::MSG_RELATED_INFO;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
else
@ -357,23 +369,33 @@ public:
/// @see RsTokenService::requestServiceStatistic
bool requestServiceStatistic(uint32_t& token)
{
mTokenService.requestServiceStatistic(token);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_SERVICE_STATS;
mTokenService.requestServiceStatistic(token,opts);
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::SERVICE_STATISTICS;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
/// @see RsTokenService::requestGroupStatistic
bool requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
{
mTokenService.requestGroupStatistic(token, grpId);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_STATS;
mTokenService.requestGroupStatistic(token, grpId,opts);
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::GROUP_STATISTICS;
#ifdef DEBUG_GXSIFACEHELPER
locked_dumpTokens();
#endif
return true;
}
@ -485,7 +507,7 @@ private:
uint32_t count[7] = {0};
std::cerr << "Service " << std::hex << service_id << std::dec
RsDbg() << "Service " << std::hex << service_id << std::dec
<< " (" << rsServiceControl->getServiceName(RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id))
<< ") this=" << std::hex << (void*)this << std::dec << ") Active tokens (per type): " ;

View file

@ -45,6 +45,13 @@ struct RsMsgMetaData;
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
enum class GxsRequestPriority {
VERY_HIGH = 0x00,
HIGH = 0x01,
NORMAL = 0x02,
LOW = 0x03,
VERY_LOW = 0x04,
};
class RsGxsGrpMetaData;
class RsGxsMsgMetaData;
@ -232,7 +239,7 @@ public:
mNumChildMsgsNew = 0;
mNumChildMsgsUnread = 0;
mSizeStore = 0;
}
}
public:
uint32_t mNumMsgs;

View file

@ -46,7 +46,8 @@ struct RsGxsNotify
TYPE_RECEIVED_NEW = 0x02,
TYPE_PROCESSED = 0x03,
TYPE_RECEIVED_PUBLISHKEY = 0x04,
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05,
TYPE_STATISTICS_CHANGED = 0x06
};
virtual ~RsGxsNotify() {}

View file

@ -114,6 +114,7 @@ enum class RsPostedEventCode: uint8_t
UPDATED_POSTED_GROUP = 0x04,
UPDATED_MESSAGE = 0x05,
READ_STATUS_CHANGED = 0x06,
STATISTICS_CHANGED = 0x07,
};

View file

@ -80,7 +80,7 @@ struct RsTokReqOptions
{
RsTokReqOptions() : mOptions(0), mStatusFilter(0), mStatusMask(0),
mMsgFlagMask(0), mMsgFlagFilter(0), mReqType(0), mSubscribeFilter(0),
mSubscribeMask(0), mBefore(0), mAfter(0) {}
mSubscribeMask(0), mBefore(0), mAfter(0),mPriority(GxsRequestPriority::NORMAL) {}
/**
* Can be one or multiple RS_TOKREQOPT_*
@ -107,6 +107,8 @@ struct RsTokReqOptions
// Time range... again applied after Options.
rstime_t mBefore;
rstime_t mAfter;
GxsRequestPriority mPriority;
};
/*!
@ -181,6 +183,25 @@ public:
*/
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::vector<RsGxsGrpMsgIdPair>& msgIds) = 0;
/*!
* This request statistics on amount of data held
* number of groups
* number of groups subscribed
* number of messages
* size of db store
* total size of messages
* total size of groups
* @param token
*/
virtual void requestServiceStatistic(uint32_t& token, const RsTokReqOptions &opts) = 0;
/*!
* To request statistic on a group
* @param token set to value to be redeemed to get statistic
* @param grpId the id of the group
*/
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId, const RsTokReqOptions &opts) = 0;
/* Poll */
@ -194,25 +215,6 @@ public:
*/
virtual GxsRequestStatus requestStatus(const uint32_t token) = 0;
/*!
* This request statistics on amount of data held
* number of groups
* number of groups subscribed
* number of messages
* size of db store
* total size of messages
* total size of groups
* @param token
*/
virtual void requestServiceStatistic(uint32_t& token) = 0;
/*!
* To request statistic on a group
* @param token set to value to be redeemed to get statistic
* @param grpId the id of the group
*/
virtual void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId) = 0;
/*!
* @brief Cancel Request
* If this function returns false, it may be that the request has completed

View file

@ -302,7 +302,6 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
switch (grpChange->getType())
{
default:
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
@ -318,6 +317,20 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
break;
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git;
for (git = grpList.begin(); git != grpList.end(); ++git)
{
auto ev = std::make_shared<RsGxsChannelEvent>();
ev->mChannelGroupId = *git;
ev->mChannelEventCode = RsChannelEventCode::STATISTICS_CHANGED;
rsEvents->postEvent(ev);
}
}
break;
case RsGxsNotify::TYPE_PUBLISHED:
case RsGxsNotify::TYPE_RECEIVED_NEW:
{
@ -356,9 +369,14 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
rsEvents->postEvent(ev);
}
}
break;
default:
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
break;
}
}
}
RsGxsDistantSearchResultChange *dsrChange = dynamic_cast<RsGxsDistantSearchResultChange*>(*it);

View file

@ -246,7 +246,6 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
switch (grpChange->getType())
{
default:
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
@ -260,7 +259,7 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
}
break;
break;
case RsGxsNotify::TYPE_PUBLISHED:
case RsGxsNotify::TYPE_RECEIVED_NEW:
@ -288,8 +287,26 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
<< " Not notifying already known forum "
<< *git << std::endl;
}
break;
}
break;
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git;
for (git = grpList.begin(); git != grpList.end(); ++git)
{
auto ev = std::make_shared<RsGxsForumEvent>();
ev->mForumGroupId = *git;
ev->mForumEventCode = RsForumEventCode::STATISTICS_CHANGED;
rsEvents->postEvent(ev);
}
}
break;
default:
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
break;
#ifdef NOT_USED_YET
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:

View file

@ -133,8 +133,7 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
#endif
switch(grpChange->getType())
{
default:
{
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
@ -148,15 +147,30 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
}
break;
break;
case RsGxsNotify::TYPE_PUBLISHED:
case RsGxsNotify::TYPE_RECEIVED_NEW:
{
/* group received */
const std::list<RsGxsGroupId>& grpList = grpChange->mGrpIdList;
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
{
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git;
for (auto git = grpList.begin(); git != grpList.end(); ++git)
for (git = grpList.begin(); git != grpList.end(); ++git)
{
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedGroupId = *git;
ev->mPostedEventCode = RsPostedEventCode::STATISTICS_CHANGED;
rsEvents->postEvent(ev);
}
}
break;
case RsGxsNotify::TYPE_PUBLISHED:
case RsGxsNotify::TYPE_RECEIVED_NEW:
{
/* group received */
const std::list<RsGxsGroupId>& grpList = grpChange->mGrpIdList;
for (auto git = grpList.begin(); git != grpList.end(); ++git)
{
if(mKnownPosted.find(*git) == mKnownPosted.end())
{
@ -178,9 +192,13 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
<< " Not notifying already known forum "
<< *git << std::endl;
}
}
}
break;
}
default:
RsErr() << " Got a GXS event of type " << grpChange->getType() << " Currently not handled." << std::endl;
break;
}
}
delete *it;