reset interest filter
diff --git a/ccnx/sync-ccnx-wrapper.cc b/ccnx/sync-ccnx-wrapper.cc
index bc1ea0f..d0a6376 100644
--- a/ccnx/sync-ccnx-wrapper.cc
+++ b/ccnx/sync-ccnx-wrapper.cc
@@ -59,19 +59,21 @@
void
CcnxWrapper::connectCcnd()
{
- /*
- if (m_handle != NULL)
- {
- ccn_destroy(&m_handle);
- }
- */
+ ccn_disconnect (m_handle);
_LOG_DEBUG("<<< connecting to ccnd");
if (ccn_connect(m_handle, NULL) < 0)
{
- //ccn_destroy(&m_handle);
_LOG_DEBUG("<<< connecting to ccnd failed");
BOOST_THROW_EXCEPTION (CcnxOperationException() << errmsg_info_str("connection to ccnd failed"));
}
+ if (!m_registeredInterests.empty())
+ {
+ for (map<std::string, InterestCallback>::const_iterator it = m_registeredInterests.begin(); it != m_registeredInterests.end(); ++it)
+ {
+ setInterestFilter(it->first, it->second);
+ _LOG_DEBUG("<<< registering interest filter for: " << it->first);
+ }
+ }
}
CcnxWrapper::~CcnxWrapper()
@@ -283,6 +285,7 @@
interest += compStr;
}
(*f) (interest);
+ _LOG_DEBUG("<<< processed interest: " << interest);
return CCN_UPCALL_RESULT_OK;
}
@@ -372,6 +375,8 @@
_LOG_ERROR("<<< Express interest failed: " << strInterest);
}
+ _LOG_DEBUG("<<< Sending interest: " << strInterest);
+
ccn_charbuf_destroy (&pname);
return 0;
}
@@ -394,6 +399,7 @@
BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("set interest filter failed") << errmsg_info_int (ret));
}
+ m_registeredInterests.insert(pair<std::string, InterestCallback>(prefix, interestCallback));
ccn_charbuf_destroy(&pname);
}
@@ -414,6 +420,7 @@
BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("set interest filter failed") << errmsg_info_int (ret));
}
+ m_registeredInterests.erase(prefix);
ccn_charbuf_destroy(&pname);
}
diff --git a/include/sync-ccnx-wrapper.h b/include/sync-ccnx-wrapper.h
index dafba33..d68cdc1 100644
--- a/include/sync-ccnx-wrapper.h
+++ b/include/sync-ccnx-wrapper.h
@@ -38,6 +38,7 @@
#include <boost/function.hpp>
#include <string>
#include <sstream>
+#include <map>
/**
* \defgroup sync SYNC protocol
@@ -150,6 +151,7 @@
boost::recursive_mutex m_mutex;
boost::thread m_thread;
bool m_running;
+ std::map<std::string, InterestCallback> m_registeredInterests;
};
typedef boost::shared_ptr<CcnxWrapper> CcnxWrapperPtr;