socket: allow manipulating multiple nodes in single logic

Change-Id: I61241f4c3d92703e975d988d593957d445942ad0
This commit is contained in:
Qiuhan Ding committed 2015-01-05 09:50:40 -08:00
1 parent d71a08a9ba
commit e246b62b1b
3 files changed
+39 -21

No files matched your search

+1 -1
View File
@@ -110,7 +110,7 @@ Logic::Logic(ndn::Face& face,
bind(&Logic::onSyncInterest, this, _1, _2),
bind(&Logic::onSyncRegisterFailed, this, _1, _2));
sendSyncInterest();
_LOG_DEBUG_ID("<< Logic::Logic");
}
+15 -7
View File
@@ -30,6 +30,7 @@ INIT_LOGGER("Socket");
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 @@ Socket::Socket(const Name& syncPrefix,
{
}
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 @@ Socket::publishData(const Block& content, const ndn::time::milliseconds& freshne
m_face.put(*data);
m_logic.updateSeqNo(newSeq);
m_logic.updateSeqNo(newSeq, prefix);
}
void
+23 -13
View File
@@ -64,19 +64,8 @@ public:
const Name& signingId = DEFAULT_NAME,
ndn::shared_ptr<ndn::Validator> validator = DEFAULT_VALIDATOR);
/**
* @brief Publish a data packet in the session and trigger synchronization updates
*
* This method will create a data packet with the supplied content.
* The packet name is the local session + seqNo.
* The seqNo is automatically maintained by internal Logic.
*
* @param buf Pointer to the bytes in content
* @param len size of the bytes in content
* @param freshness FreshnessPeriod of the data packet.
*/
void
publishData(const uint8_t* buf, size_t len, const ndn::time::milliseconds& freshness);
addSyncNode(const Name& prefix, const Name& signingId = DEFAULT_NAME);
/**
* @brief Publish a data packet in the session and trigger synchronization updates
@@ -85,11 +74,31 @@ public:
* The packet name is the local session + seqNo.
* The seqNo is automatically maintained by internal Logic.
*
* @throws It will throw error, if the prefix does not exist in m_logic
*
* @param buf Pointer to the bytes in content
* @param len size of the bytes in content
* @param freshness FreshnessPeriod of the data packet.
*/
void
publishData(const uint8_t* buf, size_t len, const ndn::time::milliseconds& freshness,
const Name& prefix = DEFAULT_PREFIX);
/**
* @brief Publish a data packet in the session and trigger synchronization updates
*
* This method will create a data packet with the supplied content.
* The packet name is the local session + seqNo.
* The seqNo is automatically maintained by internal Logic.
*
* @throws It will throw error, if the prefix does not exist in m_logic
*
* @param content Block that will be set as the content of the data packet.
* @param freshness FreshnessPeriod of the data packet.
*/
void
publishData(const Block& content, const ndn::time::milliseconds& freshness);
publishData(const Block& content, const ndn::time::milliseconds& freshness,
const Name& prefix = DEFAULT_PREFIX);
/**
* @brief Retrive a data packet with a particular seqNo from a session
@@ -146,6 +155,7 @@ private:
public:
static const ndn::Name DEFAULT_NAME;
static const ndn::Name DEFAULT_PREFIX;
static const ndn::shared_ptr<ndn::Validator> DEFAULT_VALIDATOR;
private: