socket: add remove node function
Change-Id: I6d032be0b9ed7c09e7ca14b6edb03beed9eb61db
diff --git a/src/socket.cpp b/src/socket.cpp
index 7356f73..95a9045 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -53,6 +53,15 @@
[] (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)
{
@@ -73,6 +82,24 @@
}
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)
{