util: stop using ChildSelector in NotificationSubscriber

refs #4664

Change-Id: I9e6c39d49949f0b097c220eafbe4ce990549b54d
diff --git a/ndn-cxx/util/notification-subscriber.cpp b/ndn-cxx/util/notification-subscriber.cpp
index f72aa58..8efc7a1 100644
--- a/ndn-cxx/util/notification-subscriber.cpp
+++ b/ndn-cxx/util/notification-subscriber.cpp
@@ -38,8 +38,8 @@
   : m_face(face)
   , m_prefix(prefix)
   , m_isRunning(false)
-  , m_lastSequenceNo(std::numeric_limits<uint64_t>::max())
-  , m_lastNackSequenceNo(std::numeric_limits<uint64_t>::max())
+  , m_lastSequenceNum(std::numeric_limits<uint64_t>::max())
+  , m_lastNackSequenceNum(std::numeric_limits<uint64_t>::max())
   , m_attempts(1)
   , m_scheduler(face.getIoService())
   , m_nackEvent(m_scheduler)
@@ -81,13 +81,8 @@
   auto interest = make_shared<Interest>(m_prefix);
   interest->setCanBePrefix(true);
   interest->setMustBeFresh(true);
-  interest->setChildSelector(1);
-  interest->setInterestLifetime(getInterestLifetime());
-
-  m_lastInterestId = m_face.expressInterest(*interest,
-                                            [this] (const auto&, const auto& d) { this->afterReceiveData(d); },
-                                            [this] (const auto&, const auto& n) { this->afterReceiveNack(n); },
-                                            [this] (const auto&) { this->afterTimeout(); });
+  interest->setInterestLifetime(m_interestLifetime);
+  sendInterest(*interest);
 }
 
 void
@@ -96,16 +91,19 @@
   if (shouldStop())
     return;
 
-  BOOST_ASSERT(m_lastSequenceNo != std::numeric_limits<uint64_t>::max()); // overflow or missing initial reply
-
   Name nextName = m_prefix;
-  nextName.appendSequenceNumber(m_lastSequenceNo + 1);
+  nextName.appendSequenceNumber(m_lastSequenceNum + 1);
 
   auto interest = make_shared<Interest>(nextName);
   interest->setCanBePrefix(false);
-  interest->setInterestLifetime(getInterestLifetime());
+  interest->setInterestLifetime(m_interestLifetime);
+  sendInterest(*interest);
+}
 
-  m_lastInterestId = m_face.expressInterest(*interest,
+void
+NotificationSubscriberBase::sendInterest(const Interest& interest)
+{
+  m_lastInterestId = m_face.expressInterest(interest,
                                             [this] (const auto&, const auto& d) { this->afterReceiveData(d); },
                                             [this] (const auto&, const auto& n) { this->afterReceiveNack(n); },
                                             [this] (const auto&) { this->afterTimeout(); });
@@ -131,7 +129,7 @@
     return;
 
   try {
-    m_lastSequenceNo = data.getName().get(-1).toSequenceNumber();
+    m_lastSequenceNum = data.getName().get(-1).toSequenceNumber();
   }
   catch (const tlv::Error&) {
     onDecodeError(data);
@@ -174,22 +172,22 @@
 time::milliseconds
 NotificationSubscriberBase::exponentialBackoff(lp::Nack nack)
 {
-  uint64_t nackSequenceNo;
+  uint64_t nackSequenceNum;
   try {
-    nackSequenceNo = nack.getInterest().getName().get(-1).toSequenceNumber();
+    nackSequenceNum = nack.getInterest().getName().get(-1).toSequenceNumber();
   }
   catch (const tlv::Error&) {
-    nackSequenceNo = 0;
+    nackSequenceNum = 0;
   }
 
-  if (m_lastNackSequenceNo == nackSequenceNo) {
+  if (m_lastNackSequenceNum == nackSequenceNum) {
     ++m_attempts;
   }
   else {
     m_attempts = 1;
   }
 
-  m_lastNackSequenceNo = nackSequenceNo;
+  m_lastNackSequenceNum = nackSequenceNum;
 
   return time::milliseconds(static_cast<time::milliseconds::rep>(std::pow(2, m_attempts) * 100 +
                                                                  random::generateWord32() % 100));
diff --git a/ndn-cxx/util/notification-subscriber.hpp b/ndn-cxx/util/notification-subscriber.hpp
index 2791ff5..3560743 100644
--- a/ndn-cxx/util/notification-subscriber.hpp
+++ b/ndn-cxx/util/notification-subscriber.hpp
@@ -88,6 +88,9 @@
   void
   sendNextInterest();
 
+  void
+  sendInterest(const Interest& interest);
+
   virtual bool
   hasSubscriber() const = 0;
 
@@ -132,8 +135,8 @@
   Face& m_face;
   Name m_prefix;
   bool m_isRunning;
-  uint64_t m_lastSequenceNo;
-  uint64_t m_lastNackSequenceNo;
+  uint64_t m_lastSequenceNum;
+  uint64_t m_lastNackSequenceNum;
   uint64_t m_attempts;
   util::scheduler::Scheduler m_scheduler;
   util::scheduler::ScopedEventId m_nackEvent;
diff --git a/tests/unit/util/notification-subscriber.t.cpp b/tests/unit/util/notification-subscriber.t.cpp
index 3fe3fd6..886e651 100644
--- a/tests/unit/util/notification-subscriber.t.cpp
+++ b/tests/unit/util/notification-subscriber.t.cpp
@@ -64,7 +64,7 @@
     data.setFreshnessPeriod(1_s);
     m_keyChain.sign(data);
 
-    lastDeliveredSeqNo = nextSendNotificationNo;
+    lastDeliveredSeqNum = nextSendNotificationNo;
     lastNotification.setMessage("");
     ++nextSendNotificationNo;
     subscriberFace.receive(data);
@@ -133,7 +133,7 @@
 
     const Interest& interest = subscriberFace.sentInterests[0];
     return interest.getName() == streamPrefix &&
-           interest.getChildSelector() == 1 &&
+           interest.getCanBePrefix() &&
            interest.getMustBeFresh() &&
            interest.getInterestLifetime() == subscriber.getInterestLifetime();
   }
@@ -142,7 +142,7 @@
    *          or 0 if there's no such request as sole sent Interest
    */
   uint64_t
-  getRequestSeqNo() const
+  getRequestSeqNum() const
   {
     if (subscriberFace.sentInterests.size() != 1)
       return 0;
@@ -164,7 +164,7 @@
   util::signal::Connection notificationConn;
   util::signal::Connection nackConn;
   uint64_t nextSendNotificationNo;
-  uint64_t lastDeliveredSeqNo;
+  uint64_t lastDeliveredSeqNum;
   SimpleNotification lastNotification;
   lp::Nack lastNack;
   bool hasTimeout;
@@ -205,14 +205,14 @@
   this->deliverNotification("n1");
   advanceClocks(1_ms);
   BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n1");
-  BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
+  BOOST_CHECK_EQUAL(this->getRequestSeqNum(), lastDeliveredSeqNum + 1);
 
   // respond to continuation request
   subscriberFace.sentInterests.clear();
   this->deliverNotification("n2");
   advanceClocks(1_ms);
   BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n2");
-  BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
+  BOOST_CHECK_EQUAL(this->getRequestSeqNum(), lastDeliveredSeqNum + 1);
 }
 
 BOOST_AUTO_TEST_CASE(Nack)