chunks+poke+ping: use PendingInterestHandle and RegisteredPrefixHandle

refs #4316, #3919

Change-Id: Ia95362067a9024964cf67543c76375144b8a2782
diff --git a/tools/ping/server/ping-server.cpp b/tools/ping/server/ping-server.cpp
index 9b1403d..4162b05 100644
--- a/tools/ping/server/ping-server.cpp
+++ b/tools/ping/server/ping-server.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2015-2018,  Arizona Board of Regents.
+ * Copyright (c) 2015-2019,  Arizona Board of Regents.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -33,7 +33,6 @@
   , m_face(face)
   , m_keyChain(keyChain)
   , m_nPings(0)
-  , m_regPrefixId(nullptr)
 {
   auto b = make_shared<Buffer>();
   b->assign(m_options.payloadSize, 'a');
@@ -43,20 +42,18 @@
 void
 PingServer::start()
 {
-  m_regPrefixId = m_face.setInterestFilter(
-                    Name(m_options.prefix).append("ping"),
-                    bind(&PingServer::onInterest, this, _2),
-                    [] (const auto&, const auto& reason) {
-                      BOOST_THROW_EXCEPTION(std::runtime_error("Failed to register prefix: " + reason));
-                    });
+  m_registeredPrefix = m_face.setInterestFilter(
+                       Name(m_options.prefix).append("ping"),
+                       bind(&PingServer::onInterest, this, _2),
+                       [] (const auto&, const auto& reason) {
+                         BOOST_THROW_EXCEPTION(std::runtime_error("Failed to register prefix: " + reason));
+                       });
 }
 
 void
 PingServer::stop()
 {
-  if (m_regPrefixId != nullptr) {
-    m_face.unsetInterestFilter(m_regPrefixId);
-  }
+  m_registeredPrefix.cancel();
 }
 
 size_t
diff --git a/tools/ping/server/ping-server.hpp b/tools/ping/server/ping-server.hpp
index 3a43a6d..46df6f9 100644
--- a/tools/ping/server/ping-server.hpp
+++ b/tools/ping/server/ping-server.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2015-2018,  Arizona Board of Regents.
+ * Copyright (c) 2015-2019,  Arizona Board of Regents.
  *
  * This file is part of ndn-tools (Named Data Networking Essential Tools).
  * See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -105,7 +105,7 @@
   KeyChain& m_keyChain;
   size_t m_nPings;
   Block m_payload;
-  const RegisteredPrefixId* m_regPrefixId;
+  RegisteredPrefixHandle m_registeredPrefix;
 };
 
 } // namespace server