make chronosync a dependency
refs: #2400
Change-Id: I8b488f165a4f9a2c9a7731931be3b6d2e3c43c89
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index 0e40809..09d5c27 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -156,22 +156,19 @@
// of the object
std::shared_ptr<ndn::Face> facePtr(&m_syncFace, NullDeleter<ndn::Face>());
- m_syncSocket = std::make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator, facePtr,
- std::bind(&SyncLogicHandler::onNsyncUpdate,
- this, _1, _2),
- std::bind(&SyncLogicHandler::onNsyncRemoval,
- this, _1));
+ m_syncSocket = std::make_shared<chronosync::Socket>(m_syncPrefix, m_updatePrefix, *facePtr,
+ bind(&SyncLogicHandler::onNsyncUpdate, this, _1));
}
void
-SyncLogicHandler::onNsyncUpdate(const vector<Sync::MissingDataInfo>& v, Sync::SyncSocket* socket)
+SyncLogicHandler::onNsyncUpdate(const vector<chronosync::MissingDataInfo>& v)
{
_LOG_DEBUG("Received Nsync update event");
for (size_t i = 0; i < v.size(); i++){
- _LOG_DEBUG("Update Name: " << v[i].prefix << " Seq no: " << v[i].high.getSeq());
+ _LOG_DEBUG("Update Name: " << v[i].session.getPrefix(-1).toUri() << " Seq no: " << v[i].high);
- SyncUpdate update(v[i].prefix, v[i].high.getSeq());
+ SyncUpdate update(v[i].session.getPrefix(-1), v[i].high);
processUpdateFromSync(update);
}
@@ -299,7 +296,8 @@
ndn::Name updateName(updatePrefix);
string data("NoData");
- m_syncSocket->publishData(updateName.toUri(), 0, data.c_str(), data.size(), 1000, seqNo);
+ m_syncSocket->publishData(reinterpret_cast<const uint8_t*>(data.c_str()), data.size(),
+ ndn::time::milliseconds(1000), seqNo, updateName);
}
} // namespace nlsr
diff --git a/src/communication/sync-logic-handler.hpp b/src/communication/sync-logic-handler.hpp
index 5e0e6a8..c8e143e 100644
--- a/src/communication/sync-logic-handler.hpp
+++ b/src/communication/sync-logic-handler.hpp
@@ -24,7 +24,7 @@
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/security/validator-null.hpp>
-#include <nsync/sync-socket.h>
+#include <ChronoSync/socket.hpp>
#include <iostream>
#include <unistd.h>
@@ -60,10 +60,9 @@
/*! \brief Simple wrapper function to handle updates from Sync.
\param v The information that Sync has acquired.
- \param socket The socket that Sync is using to synchronize updates.
*/
void
- onNsyncUpdate(const std::vector<Sync::MissingDataInfo>& v, Sync::SyncSocket* socket);
+ onNsyncUpdate(const std::vector<chronosync::MissingDataInfo>& v);
void
onNsyncRemoval(const std::string& prefix);
@@ -93,7 +92,7 @@
private:
std::shared_ptr<ndn::ValidatorNull> m_validator;
ndn::Face& m_syncFace;
- std::shared_ptr<Sync::SyncSocket> m_syncSocket;
+ std::shared_ptr<chronosync::Socket> m_syncSocket;
ndn::Name m_syncPrefix;
private:
diff --git a/src/conf-file-processor.hpp b/src/conf-file-processor.hpp
index 2a32cee..d6cdcbe 100644
--- a/src/conf-file-processor.hpp
+++ b/src/conf-file-processor.hpp
@@ -16,11 +16,8 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- *
- * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
- * \author Minsheng Zhang <mzhang4@memphis.edu>
- *
**/
+
#ifndef NLSR_CONF_FILE_PROCESSOR_HPP
#define NLSR_CONF_FILE_PROCESSOR_HPP
diff --git a/src/nlsr-runner.cpp b/src/nlsr-runner.cpp
index 100cf72..d5bf709 100644
--- a/src/nlsr-runner.cpp
+++ b/src/nlsr-runner.cpp
@@ -43,7 +43,7 @@
ConfFileProcessor configProcessor(m_nlsr, m_nlsr.getConfFileName());
if (!configProcessor.processConfFile()) {
- throw Error("Error in configuration file processing! Exiting from NLSR");
+ BOOST_THROW_EXCEPTION(Error("Error in configuration file processing! Exiting from NLSR"));
}
if (m_nlsr.getConfParameter().isLog4CxxConfAvailable()) {
@@ -53,16 +53,16 @@
INIT_LOGGERS(m_nlsr.getConfParameter().getLogDir(), m_nlsr.getConfParameter().getLogLevel());
}
- m_nlsr.initialize();
-
if (m_nlsr.getIsSetDaemonProcess()) {
m_nlsr.daemonize();
}
+ m_nlsr.initialize();
+
try {
m_nlsr.startEventLoop();
}
- catch (std::exception& e) {
+ catch (const std::exception& e) {
_LOG_FATAL("ERROR: " << e.what());
std::cerr << "ERROR: " << e.what() << std::endl;