try to reconnect to nfd when connection is down
Change-Id: I37ac7d6894cf058dc0453dd25425d8e1a6dc4e18
Refs: #2470
diff --git a/src/controller-backend.hpp b/src/controller-backend.hpp
index d7bda46..78865ef 100644
--- a/src/controller-backend.hpp
+++ b/src/controller-backend.hpp
@@ -5,6 +5,7 @@
* BSD license, See the LICENSE file for more information
*
* Author: Yingdi Yu <yingdi@cs.ucla.edu>
+ * Qiuhan Ding <qiuhanding@cs.ucla.edu>
*/
#ifndef CHRONOCHAT_CONTROLLER_BACKEND_HPP
@@ -22,6 +23,8 @@
#include "validator-invitation.hpp"
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/util/in-memory-storage-persistent.hpp>
+#include <boost/thread.hpp>
+#include <mutex>
#endif
namespace chronochat {
@@ -31,7 +34,7 @@
Q_OBJECT
public:
- ControllerBackend(QObject* parent = 0);
+ ControllerBackend(QObject* parent = nullptr);
~ControllerBackend();
@@ -113,6 +116,9 @@
void
invitationRequestResult(const std::string& msg);
+ void
+ nfdError();
+
public slots:
void
shutdown();
@@ -138,11 +144,16 @@
void
onSendInvitationRequest(const QString& chatroomName, const QString& prefix);
+ void
+ onNfdReconnect();
+
private slots:
void
onContactIdListReady(const QStringList& list);
private:
+ bool m_isNfdConnected;
+ bool m_shouldResume;
ndn::Face m_face;
Name m_identity; //TODO: set/get
@@ -164,6 +175,8 @@
QStringList m_chatDialogList;
QMutex m_mutex;
+ std::mutex m_resumeMutex;
+ std::mutex m_nfdConnectionMutex;
ndn::util::InMemoryStoragePersistent m_ims;
};