try to reconnect to nfd when connection is down
Change-Id: I37ac7d6894cf058dc0453dd25425d8e1a6dc4e18
Refs: #2470
diff --git a/src/chat-dialog-backend.hpp b/src/chat-dialog-backend.hpp
index f0fead3..70ebefc 100644
--- a/src/chat-dialog-backend.hpp
+++ b/src/chat-dialog-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_CHAT_DIALOG_BACKEND_HPP
@@ -18,6 +19,7 @@
#include "chatbuf.pb.h"
#include <mutex>
#include <socket.hpp>
+#include <boost/thread.hpp>
#endif
namespace chronochat {
@@ -47,7 +49,7 @@
const std::string& chatroomName,
const std::string& nick,
const Name& signingId = Name(),
- QObject* parent = 0);
+ QObject* parent = nullptr);
~ChatDialogBackend();
@@ -63,6 +65,9 @@
loadTrustAnchor();
void
+ exitChatroom();
+
+ void
close();
void
@@ -121,11 +126,20 @@
chatPrefixChanged(ndn::Name newChatPrefix);
void
+ refreshChatDialog(ndn::Name chatPrefix);
+
+ void
eraseInRoster(ndn::Name sessionPrefix, ndn::Name::Component chatroomName);
void
addInRoster(ndn::Name sessionPrefix, ndn::Name::Component chatroomName);
+ void
+ newChatroomForDiscovery(ndn::Name::Component chatroomName);
+
+ void
+ nfdError();
+
public slots:
void
sendChatMessage(QString text, time_t timestamp);
@@ -136,9 +150,14 @@
void
shutdown();
+ void
+ onNfdReconnect();
+
private:
typedef std::map<ndn::Name, UserInfo> BackendRoster;
+ bool m_shouldResume;
+ bool m_isNfdConnected;
shared_ptr<ndn::Face> m_face;
Name m_localRoutingPrefix; // routable local prefix
@@ -160,8 +179,8 @@
BackendRoster m_roster; // User roster
- std::mutex m_mutex;
- bool m_shouldResume;
+ std::mutex m_resumeMutex;
+ std::mutex m_nfdConnectionMutex;
};
} // namespace chronochat