socket: add remove node function
Change-Id: I6d032be0b9ed7c09e7ca14b6edb03beed9eb61db
This commit is contained in:
1 parent
fb8c9e0b7e
commit
03b9de39f2
2 files changed
+51
No files matched your search
@@ -53,6 +53,15 @@ Socket::Socket(const Name& syncPrefix,
|
||||
[] (const Name& prefix, const std::string& msg) {});
|
||||
}
|
||||
|
||||
Socket::~Socket()
|
||||
{
|
||||
for(const auto& itr : m_registeredPrefixList) {
|
||||
if (static_cast<bool>(itr.second))
|
||||
m_face.unsetInterestFilter(itr.second);
|
||||
}
|
||||
m_ims.erase("/");
|
||||
}
|
||||
|
||||
void
|
||||
Socket::addSyncNode(const Name& prefix, const Name& signingId)
|
||||
{
|
||||
@@ -72,6 +81,24 @@ Socket::addSyncNode(const Name& prefix, const Name& signingId)
|
||||
[] (const Name& prefix, const std::string& msg) {});
|
||||
}
|
||||
|
||||
void
|
||||
Socket::removeSyncNode(const Name& prefix)
|
||||
{
|
||||
if (prefix == DEFAULT_NAME)
|
||||
return;
|
||||
|
||||
auto itr = m_registeredPrefixList.find(prefix);
|
||||
if (itr != m_registeredPrefixList.end()) {
|
||||
if (static_cast<bool>(itr->second))
|
||||
m_face.unsetInterestFilter(itr->second);
|
||||
m_registeredPrefixList.erase(itr);
|
||||
}
|
||||
|
||||
m_ims.erase(prefix);
|
||||
m_logic.removeUserNode(prefix);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Socket::publishData(const uint8_t* buf, size_t len, const ndn::time::milliseconds& freshness,
|
||||
const Name& prefix)
|
||||
|
||||
@@ -66,9 +66,33 @@ public:
|
||||
const Name& signingId = DEFAULT_NAME,
|
||||
ndn::shared_ptr<ndn::Validator> validator = DEFAULT_VALIDATOR);
|
||||
|
||||
~Socket();
|
||||
|
||||
/**
|
||||
* @brief Add a sync node under same logic
|
||||
*
|
||||
* This method will add a new sync node in logic and then register this prefix.
|
||||
* If pass an empty prefix, it will return directly without doing anything
|
||||
* If the prefix is already registered, return directly
|
||||
*
|
||||
* @param prefix Prefix of the new node
|
||||
* @param signingId Signing ID for the packet sent out by the new node
|
||||
*/
|
||||
void
|
||||
addSyncNode(const Name& prefix, const Name& signingId = DEFAULT_NAME);
|
||||
|
||||
/**
|
||||
* @brief Remove a sync node under same logic
|
||||
*
|
||||
* This method will remove a sync node in logic, unregister this prefix
|
||||
* and then clear the in memory storage about this prefix.
|
||||
* logic will be reset after removal of this node
|
||||
*
|
||||
* @param prefix Prefix of the node to remove
|
||||
*/
|
||||
void
|
||||
removeSyncNode(const Name& prefix);
|
||||
|
||||
/**
|
||||
* @brief Publish a data packet in the session and trigger synchronization updates
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user