modify data publish class; get next seq instead of highest seq
diff --git a/model/sync-app-data-publish.cc b/model/sync-app-data-publish.cc
index bc1281b..faaf482 100644
--- a/model/sync-app-data-publish.cc
+++ b/model/sync-app-data-publish.cc
@@ -42,7 +42,7 @@
}
uint32_t
-AppDataPublish::getHighestSeq (const string &prefix, uint32_t session)
+AppDataPublish::getNextSeq (const string &prefix, uint32_t session)
{
unordered_map<string, Seq>::iterator i = m_sequenceLog.find(prefix);
@@ -62,22 +62,22 @@
uint32_t seq = 0;
try
{
- seq = getHighestSeq(name, session);
+ seq = getNextSeq(name, session);
}
catch (GetSeqException &e){
m_sequenceLog.erase(name);
}
- Seq s;
- s.session = session;
- s.seq = seq;
- m_sequenceLog[name] = s;
-
ostringstream contentNameWithSeqno;
contentNameWithSeqno << name << "/" << session << "/" << seq;
m_ccnxHandle->publishData (contentNameWithSeqno.str (), dataBuffer, freshness);
+ Seq s;
+ s.session = session;
+ s.seq = seq + 1;
+ m_sequenceLog[name] = s;
+
unordered_map<pair<string, uint32_t>, string>::iterator it = m_recentData.find(make_pair(name, session));
if (it != m_recentData.end())
m_recentData.erase(it);
diff --git a/model/sync-app-data-publish.h b/model/sync-app-data-publish.h
index 204a076..85bb9ae 100644
--- a/model/sync-app-data-publish.h
+++ b/model/sync-app-data-publish.h
@@ -68,7 +68,7 @@
* @param session session
*/
uint32_t
- getHighestSeq (const std::string &prefix, uint32_t session);
+ getNextSeq (const std::string &prefix, uint32_t session);
/**
* @brief publish data for a name prefix, updates the corresponding
diff --git a/model/sync-app-socket.cc b/model/sync-app-socket.cc
index 3dca250..fb6779d 100644
--- a/model/sync-app-socket.cc
+++ b/model/sync-app-socket.cc
@@ -46,7 +46,7 @@
bool SyncAppSocket::publish (const string &prefix, uint32_t session, const string &dataBuffer, int freshness)
{
m_publisher.publishData (prefix, session, dataBuffer, freshness);
- m_syncLogic.addLocalNames (prefix, session, m_publisher.getHighestSeq (prefix, session));
+ m_syncLogic.addLocalNames (prefix, session, m_publisher.getNextSeq (prefix, session));
}
}