handles: consolidate command prefix registrations
Previously, each command handle performs prefix registrations
separately, creating an excessive number of FIB entries in NFD.
This commit consolidates those registrations into one place,
and uses ndn::Face to dispatch Interests to command handlers.
refs #2023
Change-Id: Ia74ff970797eceac4df260e84dec727952d96489
diff --git a/src/handles/watch-handle.cpp b/src/handles/watch-handle.cpp
index 97aea8f..91eaac4 100644
--- a/src/handles/watch-handle.cpp
+++ b/src/handles/watch-handle.cpp
@@ -53,25 +53,6 @@
}
void
-WatchHandle::onRegistered(const Name& prefix)
-{
- getFace().setInterestFilter(Name().append(prefix).append("start"),
- bind(&WatchHandle::onInterest, this, _1, _2));
- getFace().setInterestFilter(Name().append(prefix).append("check"),
- bind(&WatchHandle::onCheckInterest, this, _1, _2));
- getFace().setInterestFilter(Name().append(prefix).append("stop"),
- bind(&WatchHandle::onStopInterest, this, _1, _2));
-}
-
-// onRegisterFailed for watch start.
-void
-WatchHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
-{
- std::cerr << reason << std::endl;
- BOOST_THROW_EXCEPTION(Error("watch prefix registration failed"));
-}
-
-void
WatchHandle::onValidated(const shared_ptr<const Interest>& interest, const Name& prefix)
{
RepoCommandParameter parameter;
@@ -221,11 +202,12 @@
void
WatchHandle::listen(const Name& prefix)
{
- Name baseWatchPrefix(prefix);
- baseWatchPrefix.append("watch");
- getFace().registerPrefix(baseWatchPrefix,
- bind(&WatchHandle::onRegistered, this, _1),
- bind(&WatchHandle::onRegisterFailed, this, _1, _2));
+ getFace().setInterestFilter(Name(prefix).append("watch").append("start"),
+ bind(&WatchHandle::onInterest, this, _1, _2));
+ getFace().setInterestFilter(Name(prefix).append("watch").append("check"),
+ bind(&WatchHandle::onCheckInterest, this, _1, _2));
+ getFace().setInterestFilter(Name(prefix).append("watch").append("stop"),
+ bind(&WatchHandle::onStopInterest, this, _1, _2));
}
void