examples: handle Nack in consumer
refs #3701
Change-Id: Ia6cfcefcf5a9541b09a50d1e5edaa55227908191
diff --git a/examples/consumer-with-timer.cpp b/examples/consumer-with-timer.cpp
index c08a312..8c82cf6 100644
--- a/examples/consumer-with-timer.cpp
+++ b/examples/consumer-with-timer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -50,6 +50,7 @@
m_face.expressInterest(interest,
bind(&ConsumerWithTimer::onData, this, _1, _2),
+ bind(&ConsumerWithTimer::onNack, this, _1, _2),
bind(&ConsumerWithTimer::onTimeout, this, _1));
std::cout << "Sending " << interest << std::endl;
@@ -74,6 +75,13 @@
}
void
+ onNack(const Interest& interest, const lp::Nack& nack)
+ {
+ std::cout << "received Nack with reason " << nack.getReason()
+ << " for interest " << interest << std::endl;
+ }
+
+ void
onTimeout(const Interest& interest)
{
std::cout << "Timeout " << interest << std::endl;
@@ -90,6 +98,7 @@
m_face.expressInterest(interest,
bind(&ConsumerWithTimer::onData, this, _1, _2),
+ bind(&ConsumerWithTimer::onNack, this, _1, _2),
bind(&ConsumerWithTimer::onTimeout, this, _1));
std::cout << "Sending " << interest << std::endl;
diff --git a/examples/consumer.cpp b/examples/consumer.cpp
index 4042565..0e0ff43 100644
--- a/examples/consumer.cpp
+++ b/examples/consumer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -42,6 +42,7 @@
m_face.expressInterest(interest,
bind(&Consumer::onData, this, _1, _2),
+ bind(&Consumer::onNack, this, _1, _2),
bind(&Consumer::onTimeout, this, _1));
std::cout << "Sending " << interest << std::endl;
@@ -58,6 +59,13 @@
}
void
+ onNack(const Interest& interest, const lp::Nack& nack)
+ {
+ std::cout << "received Nack with reason " << nack.getReason()
+ << " for interest " << interest << std::endl;
+ }
+
+ void
onTimeout(const Interest& interest)
{
std::cout << "Timeout " << interest << std::endl;