socket: allow manipulating multiple nodes in single logic
Change-Id: I61241f4c3d92703e975d988d593957d445942ad0
diff --git a/src/socket.cpp b/src/socket.cpp
index 45c6890..695f758 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -30,6 +30,7 @@
namespace chronosync {
+const ndn::Name Socket::DEFAULT_PREFIX;
const ndn::Name Socket::DEFAULT_NAME;
const ndn::shared_ptr<ndn::Validator> Socket::DEFAULT_VALIDATOR;
@@ -47,23 +48,30 @@
{
}
-
void
-Socket::publishData(const uint8_t* buf, size_t len, const ndn::time::milliseconds& freshness)
+Socket::addSyncNode(const Name& prefix, const Name& signingId)
{
- publishData(ndn::dataBlock(ndn::tlv::Content, buf, len), freshness);
+ m_logic.addUserNode(prefix, signingId);
}
void
-Socket::publishData(const Block& content, const ndn::time::milliseconds& freshness)
+Socket::publishData(const uint8_t* buf, size_t len, const ndn::time::milliseconds& freshness,
+ const Name& prefix)
+{
+ publishData(ndn::dataBlock(ndn::tlv::Content, buf, len), freshness, prefix);
+}
+
+void
+Socket::publishData(const Block& content, const ndn::time::milliseconds& freshness,
+ const Name& prefix)
{
shared_ptr<Data> data = make_shared<Data>();
data->setContent(content);
data->setFreshnessPeriod(freshness);
- SeqNo newSeq = m_logic.getSeqNo() + 1;
+ SeqNo newSeq = m_logic.getSeqNo(prefix) + 1;
Name dataName;
- dataName.append(m_logic.getSessionName()).appendNumber(newSeq);
+ dataName.append(m_logic.getSessionName(prefix)).appendNumber(newSeq);
data->setName(dataName);
if (m_signingId.empty())
@@ -73,7 +81,7 @@
m_face.put(*data);
- m_logic.updateSeqNo(newSeq);
+ m_logic.updateSeqNo(newSeq, prefix);
}
void