Change ChatroomInfo to contain more information

Change-Id: Ie91ced5dd9be51c8d59a0c5d881967658a58fd15
diff --git a/src/chatroom-discovery-dialog.cpp b/src/chatroom-discovery-dialog.cpp
index 327e4e7..738eb84 100644
--- a/src/chatroom-discovery-dialog.cpp
+++ b/src/chatroom-discovery-dialog.cpp
@@ -3,7 +3,6 @@
 
 namespace chronos {
 
-using std::vector;
 using ndn::Name;
 
 ChatroomDiscoveryDialog::ChatroomDiscoveryDialog(QWidget* parent)
@@ -67,7 +66,7 @@
 
     QString content;
 
-    for (vector<Name>::const_iterator nameIt = it->second.getParticipants().begin();
+    for (std::list<Name>::const_iterator nameIt = it->second.getParticipants().begin();
          nameIt != it->second.getParticipants().end(); nameIt++) {
       content.append(QString::fromStdString(nameIt->toUri())).append(",");
     }
diff --git a/src/chatroom-discovery-logic.cpp b/src/chatroom-discovery-logic.cpp
index 048d121..8d8590b 100644
--- a/src/chatroom-discovery-logic.cpp
+++ b/src/chatroom-discovery-logic.cpp
@@ -151,18 +151,18 @@
                                       const ndn::Data& data,
                                       const bool isRefreshing)
 {
-  Name::Component chatroomName = data.getName().get(OFFSET_CHATROOM_NAME);
+  // Name::Component chatroomName = data.getName().get(OFFSET_CHATROOM_NAME);
 
   ChatroomInfo chatroom;
   chatroom.wireDecode(data.getContent().blockFromValue());
-  chatroom.setName(chatroomName);
+  // chatroom.setName(chatroomName);
 
   // Tmp Disabled
   // if (chatroom.getTrustModel() == ChatroomInfo::TRUST_MODEL_WEBOFTRUST)
   //   addContacts(chatroom);
 
 
-  m_chatrooms[chatroomName] = chatroom;
+  m_chatrooms[chatroom.getName()] = chatroom;
   m_onUpdate(chatroom, true); //add
 
   time::milliseconds refreshingTime;
@@ -172,7 +172,8 @@
     refreshingTime = DEFAULT_REFRESHING_TIMER;
 
   m_scheduler.scheduleEvent(refreshingTime,
-                            bind(&ChatroomDiscoveryLogic::refreshChatroom, this, chatroomName));
+                            bind(&ChatroomDiscoveryLogic::refreshChatroom, this,
+                                 chatroom.getName()));
 
   if (!isRefreshing)
     sendDiscoveryInterest();
@@ -218,4 +219,4 @@
 }
 
 
-} //namespace chronos
+} // namespace chronos
diff --git a/src/chatroom-discovery-view-dialog.cpp b/src/chatroom-discovery-view-dialog.cpp
index 7eff07b..ac6c775 100644
--- a/src/chatroom-discovery-view-dialog.cpp
+++ b/src/chatroom-discovery-view-dialog.cpp
@@ -13,7 +13,6 @@
 
 namespace chronos {
 
-using std::vector;
 using ndn::Name;
 
 ChatroomDiscoveryViewDialog::ChatroomDiscoveryViewDialog(QWidget* parent)
@@ -52,10 +51,10 @@
 }
 
 void
-ChatroomDiscoveryViewDialog::setChatroomParticipants(const vector<Name>& participants)
+ChatroomDiscoveryViewDialog::setChatroomParticipants(const std::list<Name>& participants)
 {
   QString content;
-  for (vector<Name>::const_iterator it = participants.begin();
+  for (std::list<Name>::const_iterator it = participants.begin();
        it != participants.end(); it++) {
     content.append(QString::fromStdString(it->toUri())).append("\n");
   }
diff --git a/src/chatroom-discovery-view-dialog.hpp b/src/chatroom-discovery-view-dialog.hpp
index d074e71..bb29b7a 100644
--- a/src/chatroom-discovery-view-dialog.hpp
+++ b/src/chatroom-discovery-view-dialog.hpp
@@ -39,7 +39,7 @@
   setChatroomTrustModel(QString chatroomTrustModel);
 
   void
-  setChatroomParticipants(const std::vector<ndn::Name>& chatroomParticipants);
+  setChatroomParticipants(const std::list<ndn::Name>& chatroomParticipants);
 
 
 private slots:
diff --git a/src/chatroom-info.cpp b/src/chatroom-info.cpp
index 2b23719..f6b81e3 100644
--- a/src/chatroom-info.cpp
+++ b/src/chatroom-info.cpp
@@ -27,27 +27,62 @@
 {
   size_t totalLength = 0;
 
-  //Chatroom := CHATROOM-TYPE TLV-LENGTH
-  //              TrustModel
-  //              Participant+
+  // ChatroomInfo := CHATROOM-INFO-TYPE TLV-LENGTH
+  //                   ChatroomName
+  //                   TrustModel
+  //                   ChatroomPrefix
+  //                   ManagerPrefix
+  //                   Participants
+  //
+  // ChatroomName := CHATROOM-NAME-TYPE TLV-LENGTH
+  //                   NameComponent
+  //
+  // TrustModel := TRUST-MODEL-TYPE TLV-LENGTH
+  //                 nonNegativeInteger
+  //
+  // ChatroomPrefix := CHATROOM-PREFIX-TYPE TLV-LENGTH
+  //                     Name
+  //
+  // ManagerPrefix := MANAGER-PREFIX-TYPE TLV-LENGTH
+  //                    Name
+  //
+  // Participants := PARTICIPANTS-TYPE TLV-LENGTH
+  //                   Name+
 
-  //Participants
-  for (std::vector<Name>::const_reverse_iterator it = m_participants.rbegin();
+  // Participants
+  size_t participantsLength = 0;
+  for (std::list<Name>::const_reverse_iterator it = m_participants.rbegin();
        it != m_participants.rend(); ++it) {
-    size_t entryLength = 0;
-
-    entryLength += it->wireEncode(block);
-    entryLength += block.prependVarNumber(entryLength);
-    entryLength += block.prependVarNumber(tlv::PARTICIPANT);
-    totalLength += entryLength;
+    participantsLength += it->wireEncode(block);
   }
+  participantsLength += block.prependVarNumber(participantsLength);
+  participantsLength += block.prependVarNumber(tlv::Participants);
+  totalLength += participantsLength;
 
-  //TrustModel
-  totalLength += prependNonNegativeIntegerBlock(block, tlv::TRUSTMODEL, m_trustModel);
+  // Manager Prefix
+  size_t managerLength = m_manager.wireEncode(block);
+  totalLength += managerLength;
+  totalLength += block.prependVarNumber(managerLength);
+  totalLength += block.prependVarNumber(tlv::ManagerPrefix);
 
-  //type = TYPE_CHATROOM;
+  // Chatroom Sync Prefix
+  size_t chatroomSyncPrefixLength = m_syncPrefix.wireEncode(block);
+  totalLength += chatroomSyncPrefixLength;
+  totalLength += block.prependVarNumber(chatroomSyncPrefixLength);
+  totalLength += block.prependVarNumber(tlv::ChatroomPrefix);
+
+  // Trust Model
+  totalLength += prependNonNegativeIntegerBlock(block, tlv::TrustModel, m_trustModel);
+
+  // Chatroom Name
+  size_t chatroomNameLength = m_chatroomName.wireEncode(block);
+  totalLength += chatroomNameLength;
+  totalLength += block.prependVarNumber(chatroomNameLength);
+  totalLength += block.prependVarNumber(tlv::ChatroomName);
+
+  // Chatroom Info
   totalLength += block.prependVarNumber(totalLength);
-  totalLength += block.prependVarNumber(tlv::CHATROOM);
+  totalLength += block.prependVarNumber(tlv::ChatroomInfo);
 
   return totalLength;
 }
@@ -75,37 +110,102 @@
 
   m_participants.clear();
 
-  //Chatroom := CHATROOM-TYPE TLV-LENGTH
-  //              TrustModel
-  //              Participant+
+  // ChatroomInfo := CHATROOM-INFO-TYPE TLV-LENGTH
+  //                   ChatroomName
+  //                   TrustModel
+  //                   ChatroomPrefix
+  //                   ManagerPrefix
+  //                   Participants
+  //
+  // ChatroomName := CHATROOM-NAME-TYPE TLV-LENGTH
+  //                   NameComponent
+  //
+  // TrustModel := TRUST-MODEL-TYPE TLV-LENGTH
+  //                 nonNegativeInteger
+  //
+  // ChatroomPrefix := CHATROOM-PREFIX-TYPE TLV-LENGTH
+  //                     Name
+  //
+  // ManagerPrefix := MANAGER-PREFIX-TYPE TLV-LENGTH
+  //                    Name
+  //
+  // Participants := PARTICIPANTS-TYPE TLV-LENGTH
+  //                   Name+
 
-  if (m_wire.type() != tlv::CHATROOM)
+  if (m_wire.type() != tlv::ChatroomInfo)
     throw Error("Unexpected TLV number when decoding chatroom packet");
 
+  // Chatroom Info
   Block::element_const_iterator i = m_wire.elements_begin();
 
-  //TrustModel
-  if (i == m_wire.elements_end() || i->type() != tlv::TRUSTMODEL)
+  if (i == m_wire.elements_end() || i->type() != tlv::ChatroomName)
+    throw Error("Missing Chatroom Name Info");
+  m_chatroomName.wireDecode(i->blockFromValue());
+
+  ++i;
+
+  // Trust Model
+  if (i == m_wire.elements_end() || i->type() != tlv::TrustModel)
     throw Error("Missing TrustModel");
   m_trustModel =
       static_cast<TrustModel>(readNonNegativeInteger(*i));
 
   ++i;
 
-  //Participants
-  for (; i != m_wire.elements_end() && i->type() == tlv::PARTICIPANT; ++i) {
-    Name name;
-    name.wireDecode(i->blockFromValue());
-    m_participants.push_back(name);
+  // Chatroom Sync Prefix
+  if (i == m_wire.elements_end() || i->type() != tlv::ChatroomPrefix)
+    throw Error("Missing Chatroom Prefix");
+  m_syncPrefix.wireDecode(i->blockFromValue());
+
+  ++i;
+
+  // Manager Prefix
+  if (i == m_wire.elements_end() || i->type() != tlv::ManagerPrefix)
+    throw Error("Missing Manager Prefix");
+  m_manager.wireDecode(i->blockFromValue());
+  ++i;
+
+  // Participants
+  if (i == m_wire.elements_end() || i->type() != tlv::Participants)
+    throw Error("Missing Participant");
+
+  Block temp = *i;
+  temp.parse();
+
+  Block::element_const_iterator j = temp.elements_begin();
+
+  while (j != temp.elements_end() && j->type() == tlv::Name) {
+    m_participants.push_back(Name(*j));
+    ++j;
   }
+  if (j != temp.elements_end())
+    throw Error("Unexpected element");
+
   if (m_participants.empty())
     throw Error("Missing Participant");
+
+  ++i;
+
   if (i != m_wire.elements_end()) {
     throw Error("Unexpected element");
   }
 }
 
 void
+ChatroomInfo::setName(const Name::Component& name)
+{
+  m_wire.reset();
+  m_chatroomName = name;
+}
+
+void
+ChatroomInfo::setTrustModel(const TrustModel trustModel)
+{
+  m_wire.reset();
+  m_trustModel = trustModel;
+}
+
+void
 ChatroomInfo::addParticipant(const Name& participant)
 {
   m_wire.reset();
@@ -113,24 +213,24 @@
 }
 
 void
-ChatroomInfo::addContact(const Name& contact)
+ChatroomInfo::removeParticipant(const Name& participant)
 {
   m_wire.reset();
-  m_contacts.push_back(contact);
+  m_participants.remove(participant);
 }
 
 void
-ChatroomInfo::setName(const Name::Component& name)
+ChatroomInfo::setSyncPrefix(const Name& prefix)
 {
   m_wire.reset();
-  m_name = name;
+  m_syncPrefix = prefix;
 }
 
 void
-ChatroomInfo::setTrustModel(const TrustModel trustModel)
+ChatroomInfo::setManager(const Name& manager)
 {
   m_wire.reset();
-  m_trustModel = trustModel;
+  m_manager = manager;
 }
 
-} //namespace chronos
+} // namespace chronos
diff --git a/src/chatroom-info.hpp b/src/chatroom-info.hpp
index e182713..fc7c707 100644
--- a/src/chatroom-info.hpp
+++ b/src/chatroom-info.hpp
@@ -22,6 +22,7 @@
 #include <ndn-cxx/encoding/encoding-buffer.hpp>
 #include <ndn-cxx/exclude.hpp>
 #include <boost/concept_check.hpp>
+#include <list>
 
 namespace chronos {
 
@@ -44,7 +45,6 @@
     }
   };
 
-
   enum TrustModel {
     TRUST_MODEL_HIERARCHICAL = 2,
     TRUST_MODEL_WEBOFTRUST = 1,
@@ -67,26 +67,35 @@
   const Name::Component&
   getName() const;
 
+  const TrustModel
+  getTrustModel() const;
+
+  const Name&
+  getSyncPrefix() const;
+
+  const Name&
+  getManagerPrefix() const;
+
+  const std::list<Name>&
+  getParticipants() const;
+
   void
   setName(const Name::Component& name);
 
-  const std::vector<Name>&
-  getParticipants() const;
+  void
+  setTrustModel(const TrustModel trustModel);
 
   void
   addParticipant(const Name& participant);
 
-  const std::vector<Name>&
-  getContacts() const;
+  void
+  removeParticipant(const Name& participant);
 
   void
-  addContact(const Name& contact);
-
-  const TrustModel
-  getTrustModel() const;
+  setSyncPrefix(const Name& prefix);
 
   void
-  setTrustModel(const TrustModel trustModel);
+  setManager(const Name& manager);
 
 private:
   template<bool T>
@@ -95,29 +104,18 @@
 
 private:
   mutable Block m_wire;
-  Name::Component m_name;
-  std::vector<Name> m_participants;
+  Name::Component m_chatroomName;
+  std::list<Name> m_participants;
+  Name m_manager;
+  Name m_syncPrefix;
   TrustModel m_trustModel;
-  std::vector<Name> m_contacts;
 
 };
 
 inline const Name::Component&
 ChatroomInfo::getName() const
 {
-  return m_name;
-}
-
-inline const std::vector<Name>&
-ChatroomInfo::getParticipants() const
-{
-  return m_participants;
-}
-
-inline const std::vector<Name>&
-ChatroomInfo::getContacts() const
-{
-  return m_contacts;
+  return m_chatroomName;
 }
 
 inline const ChatroomInfo::TrustModel
@@ -126,6 +124,25 @@
   return m_trustModel;
 }
 
+
+inline const Name&
+ChatroomInfo::getManagerPrefix() const
+{
+  return m_manager;
+}
+
+inline const Name&
+ChatroomInfo::getSyncPrefix() const
+{
+  return m_syncPrefix;
+}
+
+inline const std::list<Name>&
+ChatroomInfo::getParticipants() const
+{
+  return m_participants;
+}
+
 BOOST_CONCEPT_ASSERT((ndn::WireEncodable<ChatroomInfo>));
 BOOST_CONCEPT_ASSERT((ndn::WireDecodable<ChatroomInfo>));
 
diff --git a/src/chatroom-tlv.hpp b/src/chatroom-tlv.hpp
index 954fbb5..c69c639 100644
--- a/src/chatroom-tlv.hpp
+++ b/src/chatroom-tlv.hpp
@@ -6,13 +6,16 @@
 namespace tlv {
 
 enum {
-  PARTICIPANT = 128,
-  CHATROOM = 129,
-  TRUSTMODEL = 130
+  ChatroomInfo = 128,
+  ChatroomName = 129,
+  TrustModel = 130,
+  ChatroomPrefix = 131,
+  ManagerPrefix = 132,
+  Participants = 133,
 };
 
-} //namespace tlv
+} // namespace tlv
 
-} //namespace chronos
+} // namespace chronos
 
-#endif //CHRONOCHAT_CHATROOM_TLV_HPP
+#endif // CHRONOCHAT_CHATROOM_TLV_HPP
diff --git a/test/test-chatroom-discovery-logic.cpp b/test/test-chatroom-discovery-logic.cpp
deleted file mode 100644
index 1714e8a..0000000
--- a/test/test-chatroom-discovery-logic.cpp
+++ /dev/null
@@ -1,328 +0,0 @@
-#include "chatroom-discovery-logic.hpp"
-#include <boost/test/unit_test.hpp>
-#include "dummy-client-face.hpp"
-
-namespace chronos {
-
-namespace test {
-
-using std::string;
-
-BOOST_AUTO_TEST_SUITE(TestChatroomDiscoveryLogic)
-
-class Fixture
-{
-public:
-  Fixture()
-    : face(makeDummyClientFace())
-  {
-  }
-
-  void
-  update(const ChatroomInfo& chatroomName, bool isAdd)
-  {
-  }
-
-public:
-  shared_ptr<DummyClientFace> face;
-};
-
-BOOST_FIXTURE_TEST_CASE(AddLocalChatroom, Fixture)
-{
-  ChatroomDiscoveryLogic chatroomDiscoveryLogic(face, bind(&Fixture::update, this, _1, _2));
-
-  ChatroomInfo chatroom;
-  chatroom.setName(ndn::Name::Component("lunch-talk"));
-  chatroom.addParticipant(Name("/ndn/ucla/ymj"));
-  chatroom.addParticipant(Name("/ndn/ucla/alice"));
-  chatroom.setTrustModel(ChatroomInfo::TRUST_MODEL_WEBOFTRUST);
-  chatroomDiscoveryLogic.addLocalChatroom(chatroom);
-
-  ndn::Name::Component chatroomName("lunch-talk");
-
-  BOOST_CHECK_EQUAL(chatroomDiscoveryLogic.getChatrooms().size(), 1);
-  BOOST_CHECK_EQUAL(chatroom.getName(),
-                    chatroomDiscoveryLogic.getChatrooms().find(chatroomName)
-                    ->second.getName());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants().size(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second.getParticipants().size());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[0].toUri(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second
-                    .getParticipants()[0].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[1].toUri(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second
-                    .getParticipants()[1].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getTrustModel(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second.getTrustModel());
-}
-
-BOOST_FIXTURE_TEST_CASE(RemoveLocalChatroom, Fixture)
-{
-  ChatroomDiscoveryLogic chatroomDiscoveryLogic(face, bind(&Fixture::update, this, _1, _2));
-
-  ChatroomInfo chatroom;
-  chatroom.setName(ndn::Name::Component("lunch-talk"));
-  chatroom.addParticipant(Name("/ndn/ucla/ymj"));
-  chatroom.addParticipant(Name("/ndn/ucla/alice"));
-  chatroom.setTrustModel(ChatroomInfo::TRUST_MODEL_WEBOFTRUST);
-  chatroomDiscoveryLogic.addLocalChatroom(chatroom);
-
-  ndn::Name::Component chatroomName1("lunch-talk");
-  ndn::Name::Component chatroomName2("supper-talk");
-
-  chatroomDiscoveryLogic.removeLocalChatroom(chatroomName2);
-
-  BOOST_CHECK_EQUAL(chatroomDiscoveryLogic.getChatrooms().size(), 1);
-  BOOST_CHECK_EQUAL(chatroom.getName(),
-                    chatroomDiscoveryLogic.getChatrooms().find(chatroomName1)
-                    ->second.getName());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants().size(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName1)->second.getParticipants().size());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[0].toUri(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName1)->second
-                    .getParticipants()[0].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[1].toUri(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName1)->second
-                    .getParticipants()[1].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getTrustModel(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName1)->second.getTrustModel());
-
-  chatroomDiscoveryLogic.removeLocalChatroom(chatroomName1);
-  BOOST_CHECK_EQUAL(chatroomDiscoveryLogic.getChatrooms().size(), 0);
-}
-
-BOOST_FIXTURE_TEST_CASE(sendChatroomInterestFunction, Fixture)
-{
-  ChatroomDiscoveryLogic chatroomDiscoveryLogic(face, bind(&Fixture::update, this, _1, _2));
-  chatroomDiscoveryLogic.sendDiscoveryInterest();
-
-  face->processEvents(time::milliseconds(100));
-
-  //with no exclude filter
-  BOOST_CHECK_EQUAL(face->m_sentInterests.size(), 2);//first is nfd register interest
-  BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
-  BOOST_CHECK_EQUAL(face->m_sentInterests[1].getName().toUri(),
-                    ChatroomDiscoveryLogic::DISCOVERY_PREFIX.toUri());
-  BOOST_CHECK_EQUAL(face->m_sentInterests[1].getExclude().size(), 0);
-
-  face->m_sentInterests.clear();
-
-  //with exclude filter
-  ChatroomInfo chatroom;
-  chatroom.setName(ndn::Name::Component("lunch-talk"));
-  chatroom.addParticipant(Name("/ndn/ucla/ymj"));
-  chatroom.addParticipant(Name("/ndn/ucla/alice"));
-  chatroom.setTrustModel(ChatroomInfo::TRUST_MODEL_WEBOFTRUST);
-  chatroomDiscoveryLogic.addLocalChatroom(chatroom);
-
-  chatroomDiscoveryLogic.sendDiscoveryInterest();
-  face->processEvents(time::milliseconds(100));
-
-  BOOST_CHECK_EQUAL(face->m_sentInterests.size(), 1);
-  BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
-  BOOST_CHECK_EQUAL(face->m_sentInterests[0].getName().toUri(),
-                    ChatroomDiscoveryLogic::DISCOVERY_PREFIX.toUri());
-  BOOST_CHECK_EQUAL(face->m_sentInterests[0].getExclude().size(), 1);
-  BOOST_CHECK_EQUAL(face->m_sentInterests[0].getExclude().toUri(), "lunch-talk");
-}
-
-BOOST_FIXTURE_TEST_CASE(onDiscoveryInterest, Fixture)
-{
-  face->m_sentInterests.clear();
-  face->m_sentDatas.clear();
-
-  Interest discovery(ChatroomDiscoveryLogic::DISCOVERY_PREFIX);
-  discovery.setMustBeFresh(true);
-  discovery.setInterestLifetime(time::milliseconds(10000));
-
-  Exclude exclude;
-  exclude.excludeOne(ndn::Name::Component("lunch-talk"));
-  discovery.setExclude(exclude);
-
-  ChatroomDiscoveryLogic chatroomDiscoveryLogic(face, bind(&Fixture::update, this, _1, _2));
-
-  ChatroomInfo chatroom1;
-  chatroom1.setName(ndn::Name::Component("lunch-talk"));
-  chatroom1.addParticipant(Name("/ndn/ucla/ymj"));
-  chatroom1.addParticipant(Name("/ndn/ucla/alice"));
-  chatroom1.setTrustModel(ChatroomInfo::TRUST_MODEL_WEBOFTRUST);
-  chatroomDiscoveryLogic.addLocalChatroom(chatroom1);
-
-  ChatroomInfo chatroom2;
-  chatroom2.setName(ndn::Name::Component("supper-talk"));
-  chatroom2.addParticipant(Name("/ndn/ucla/bob"));
-  chatroom2.addParticipant(Name("/ndn/ucla/peter"));
-  chatroom2.setTrustModel(ChatroomInfo::TRUST_MODEL_HIERARCHICAL);
-  chatroomDiscoveryLogic.addLocalChatroom(chatroom2);
-
-  //discovery
-  chatroomDiscoveryLogic.onDiscoveryInterest(ChatroomDiscoveryLogic::DISCOVERY_PREFIX, discovery);
-
-  face->processEvents(time::milliseconds(100));
-
-  BOOST_CHECK_EQUAL(face->m_sentInterests.size(), 1);//the interest is for nfd register
-  BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 1);
-
-  ChatroomInfo chatroom;
-  chatroom.wireDecode(face->m_sentDatas[0].getContent().blockFromValue());
-  chatroom.setName(face->m_sentDatas[0].getName()
-                                      .get(ChatroomDiscoveryLogic::OFFSET_CHATROOM_NAME));
-
-  BOOST_CHECK_EQUAL(chatroom.getName(), chatroom2.getName());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants().size(),
-                    chatroom2.getParticipants().size());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[0].toUri(),
-                    chatroom2.getParticipants()[0].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[1].toUri(),
-                    chatroom2.getParticipants()[1].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getTrustModel(),
-                    chatroom2.getTrustModel());
-
-  //refreshing
-  face->m_sentInterests.clear();
-  face->m_sentDatas.clear();
-
-  Name name = ChatroomDiscoveryLogic::DISCOVERY_PREFIX;
-  name.append(Name("supper-talk"));
-
-  Interest refreshing(name);
-  refreshing.setMustBeFresh(true);
-  refreshing.setInterestLifetime(time::milliseconds(10000));
-
-  chatroomDiscoveryLogic.onDiscoveryInterest(name, refreshing);
-  face->processEvents(time::milliseconds(100));
-
-  BOOST_CHECK_EQUAL(face->m_sentInterests.size(), 0);
-  BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 1);
-
-  chatroom.wireDecode(face->m_sentDatas[0].getContent().blockFromValue());
-  chatroom.setName(face->m_sentDatas[0].getName()
-                                      .get(ChatroomDiscoveryLogic::OFFSET_CHATROOM_NAME));
-
-  BOOST_CHECK_EQUAL(chatroom.getName(), chatroom2.getName());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants().size(),
-                    chatroom2.getParticipants().size());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[0].toUri(),
-                    chatroom2.getParticipants()[0].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[1].toUri(),
-                    chatroom2.getParticipants()[1].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getTrustModel(),
-                    chatroom2.getTrustModel());
-}
-
-BOOST_FIXTURE_TEST_CASE(refreshChatroomFunction, Fixture)
-{
-  ChatroomDiscoveryLogic chatroomDiscoveryLogic(face, bind(&Fixture::update, this, _1, _2));
-
-  ChatroomInfo chatroom1;
-  chatroom1.setName(ndn::Name::Component("lunch-talk"));
-  chatroom1.addParticipant(Name("/ndn/ucla/ymj"));
-  chatroom1.addParticipant(Name("/ndn/ucla/alice"));
-  chatroom1.setTrustModel(ChatroomInfo::TRUST_MODEL_WEBOFTRUST);
-  chatroomDiscoveryLogic.addLocalChatroom(chatroom1);
-
-  chatroomDiscoveryLogic.refreshChatroom(ndn::Name::Component("lunch-talk"));
-  face->processEvents(time::milliseconds(100));
-
-  BOOST_CHECK_EQUAL(face->m_sentInterests.size(), 2);
-  BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
-
-  Name name = ChatroomDiscoveryLogic::DISCOVERY_PREFIX;
-  name.append(Name("lunch-talk"));
-
-  BOOST_CHECK_EQUAL(face->m_sentInterests[1].getName().toUri(), name.toUri());
-  BOOST_CHECK_EQUAL(face->m_sentInterests[1].getExclude().size(), 0);
-}
-
-BOOST_FIXTURE_TEST_CASE(onReceiveData, Fixture)
-{
-  ChatroomDiscoveryLogic chatroomDiscoveryLogic(face, bind(&Fixture::update, this, _1, _2));
-
-  //discovery
-  Interest discovery(ChatroomDiscoveryLogic::DISCOVERY_PREFIX);
-  discovery.setMustBeFresh(true);
-  discovery.setInterestLifetime(time::milliseconds(10000));
-
-  Name dataName(ChatroomDiscoveryLogic::DISCOVERY_PREFIX);
-  dataName.append(ndn::Name::Component("lunch-talk"));
-
-  ChatroomInfo chatroom1;
-  chatroom1.setName(ndn::Name::Component("lunch-talk"));
-  chatroom1.addParticipant(Name("/ndn/ucla/ymj"));
-  chatroom1.addParticipant(Name("/ndn/ucla/alice"));
-  chatroom1.setTrustModel(ChatroomInfo::TRUST_MODEL_WEBOFTRUST);
-
-  shared_ptr<Data> chatroomInfo = make_shared<Data>(dataName);
-  chatroomInfo->setFreshnessPeriod(time::seconds(10));
-  chatroomInfo->setContent(chatroom1.wireEncode());
-
-  chatroomDiscoveryLogic.onReceiveData(discovery, *chatroomInfo, false);
-
-  face->processEvents(time::milliseconds(1000));
-
-  ndn::Name::Component chatroomName("lunch-talk");
-
-  BOOST_CHECK_EQUAL(chatroomDiscoveryLogic.getChatrooms().size(), 1);
-  BOOST_CHECK_EQUAL(chatroom1.getName(),
-                    chatroomDiscoveryLogic.getChatrooms().find(chatroomName)
-                    ->second.getName());
-  BOOST_CHECK_EQUAL(chatroom1.getParticipants().size(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second.getParticipants().size());
-  BOOST_CHECK_EQUAL(chatroom1.getParticipants()[0].toUri(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second
-                    .getParticipants()[0].toUri());
-  BOOST_CHECK_EQUAL(chatroom1.getParticipants()[1].toUri(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second
-                    .getParticipants()[1].toUri());
-  BOOST_CHECK_EQUAL(chatroom1.getTrustModel(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second.getTrustModel());
-
-  //refreshing
-  Name name = ChatroomDiscoveryLogic::DISCOVERY_PREFIX;
-  name.append(Name("lunch-talk"));
-
-  Interest refreshing(name);
-  refreshing.setMustBeFresh(true);
-  refreshing.setInterestLifetime(time::milliseconds(10000));
-
-  chatroomDiscoveryLogic.onReceiveData(discovery, *chatroomInfo, false);
-
-  face->processEvents(time::milliseconds(1000));
-
-  BOOST_CHECK_EQUAL(chatroomDiscoveryLogic.getChatrooms().size(), 1);
-  BOOST_CHECK_EQUAL(chatroom1.getName(),
-                    chatroomDiscoveryLogic.getChatrooms().find(chatroomName)
-                    ->second.getName());
-  BOOST_CHECK_EQUAL(chatroom1.getParticipants().size(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second.getParticipants().size());
-  BOOST_CHECK_EQUAL(chatroom1.getParticipants()[0].toUri(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second
-                    .getParticipants()[0].toUri());
-  BOOST_CHECK_EQUAL(chatroom1.getParticipants()[1].toUri(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second
-                    .getParticipants()[1].toUri());
-  BOOST_CHECK_EQUAL(chatroom1.getTrustModel(),
-                    chatroomDiscoveryLogic
-                    .getChatrooms().find(chatroomName)->second.getTrustModel());
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-
-} // namespace chronos
diff --git a/test/test-chatroom-info.cpp b/test/test-chatroom-info.cpp
index a1b444e..39a5006 100644
--- a/test/test-chatroom-info.cpp
+++ b/test/test-chatroom-info.cpp
@@ -11,10 +11,19 @@
 BOOST_AUTO_TEST_SUITE(TestChatroomInfo)
 
 const uint8_t chatroomInfo[] = {
-  0x81, 0x2d, // ChatroomInfo
+  0x80, 0x5d, // ChatroomInfo
+    0x81, 0x06, // ChatroomName
+      0x08, 0x04,
+        0x06e, 0x64, 0x6e, 0x64,
     0x82, 0x01, // TrustModel
       0x01,
-    0x80, 0x14,// Participant1
+    0x83, 0x12, // ChatroomPrefix
+      0x07, 0x10,
+        0x08, 0x03,
+          0x6e, 0x64, 0x6e,
+        0x08, 0x09,
+          0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+    0x84, 0x14, // ManagerPrefix
       0x07, 0x12,
         0x08, 0x03,
           0x6e, 0x64, 0x6e,
@@ -22,7 +31,14 @@
           0x75, 0x63, 0x6c, 0x61,
         0x08, 0x05,
           0x61, 0x6c, 0x69, 0x63, 0x65,
-    0x80, 0x12, // Participant2
+    0x85, 0x26,// Participants
+      0x07, 0x12,
+        0x08, 0x03,
+          0x6e, 0x64, 0x6e,
+        0x08, 0x04,
+          0x75, 0x63, 0x6c, 0x61,
+        0x08, 0x05,
+          0x61, 0x6c, 0x69, 0x63, 0x65,
       0x07, 0x10,
         0x08, 0x03,
           0x6e, 0x64, 0x6e,
@@ -34,17 +50,41 @@
 
 BOOST_AUTO_TEST_CASE(EncodeChatroom)
 {
-  //Chatroom := CHATROOM-TYPE TLV-LENGTH
-  //              TrustModel
-  //              Participant+
+
+  // ChatroomInfo := CHATROOM-INFO-TYPE TLV-LENGTH
+  //                   ChatroomName
+  //                   TrustModel
+  //                   ChatroomPrefix
+  //                   ManagerPrefix
+  //                   Participants
+  //
+  // ChatroomName := CHATROOM-NAME-TYPE TLV-LENGTH
+  //                   NameComponent
+  //
+  // TrustModel := TRUST-MODEL-TYPE TLV-LENGTH
+  //                 nonNegativeInteger
+  //
+  // ChatroomPrefix := CHATROOM-PREFIX-TYPE TLV-LENGTH
+  //                     Name
+  //
+  // ManagerPrefix := MANAGER-PREFIX-TYPE TLV-LENGTH
+  //                    Name
+  //
+  // Participants := PARTICIPANTS-TYPE TLV-LENGTH
+  //                   Name+
 
   ChatroomInfo chatroom;
-  chatroom.setName(ndn::Name::Component("lunch-talk"));
+  chatroom.setName(ndn::Name::Component("ndnd"));
+  chatroom.setManager("/ndn/ucla/alice");
+  chatroom.setSyncPrefix("/ndn/broadcast");
   chatroom.addParticipant(Name("/ndn/ucla/alice"));
   chatroom.addParticipant(Name("/ndn/ucla/ymj"));
+  chatroom.addParticipant(Name("/ndn/ucla"));
+  chatroom.removeParticipant(Name("/ndn/ucla"));
   chatroom.setTrustModel(ChatroomInfo::TRUST_MODEL_WEBOFTRUST);
 
   const Block& encoded = chatroom.wireEncode();
+
   Block chatroomInfoBlock(chatroomInfo, sizeof(chatroomInfo));
 
   BOOST_CHECK_EQUAL_COLLECTIONS(chatroomInfoBlock.wire(),
@@ -56,7 +96,9 @@
 BOOST_AUTO_TEST_CASE(DecodeChatroomCorrect)
 {
   ChatroomInfo chatroom;
-  chatroom.setName(ndn::Name::Component("lunch-talk"));
+  chatroom.setName(ndn::Name::Component("ndnd"));
+  chatroom.setManager("/ndn/ucla/alice");
+  chatroom.setSyncPrefix("/ndn/broadcast");
   chatroom.addParticipant(Name("/ndn/ucla/alice"));
   chatroom.addParticipant(Name("/ndn/ucla/ymj"));
   chatroom.setTrustModel(ChatroomInfo::TRUST_MODEL_WEBOFTRUST);
@@ -64,22 +106,33 @@
   Block chatroomInfoBlock(chatroomInfo, sizeof(chatroomInfo));
   ChatroomInfo dechatroom;
   dechatroom.wireDecode(chatroomInfoBlock);
-  dechatroom.setName(ndn::Name::Component("lunch-talk"));
 
   BOOST_CHECK_EQUAL(chatroom.getName(), dechatroom.getName());
+  BOOST_CHECK_EQUAL(chatroom.getSyncPrefix().toUri(), dechatroom.getSyncPrefix().toUri());
+  BOOST_CHECK_EQUAL(chatroom.getManagerPrefix().toUri(), dechatroom.getManagerPrefix().toUri());
   BOOST_CHECK_EQUAL(chatroom.getParticipants().size(), dechatroom.getParticipants().size());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[0].toUri(), dechatroom.getParticipants()[0].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[1].toUri(), dechatroom.getParticipants()[1].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getTrustModel(), dechatroom.getTrustModel());
+  BOOST_CHECK_EQUAL(chatroom.getParticipants().begin()->toUri(),
+                    dechatroom.getParticipants().begin()->toUri());
+  BOOST_CHECK_EQUAL(chatroom.getParticipants().begin()->toUri(),
+                    dechatroom.getParticipants().begin()->toUri());
 }
 
 BOOST_AUTO_TEST_CASE(DecodeChatroomError)
 {
   const uint8_t error1[] = {
-    0x80, 0x2d, // Wrong ChatroomInfo Type (0x81, 0x2d)
+    0x81, 0x5d, // ChatroomInfo Type Error
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
       0x82, 0x01, // TrustModel
         0x01,
-      0x80, 0x14,// Participant1
+      0x83, 0x12, // ChatroomPrefix
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+      0x84, 0x14, // ManagerPrefix
         0x07, 0x12,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -87,7 +140,14 @@
             0x75, 0x63, 0x6c, 0x61,
           0x08, 0x05,
             0x61, 0x6c, 0x69, 0x63, 0x65,
-      0x80, 0x12, // Participant2
+      0x85, 0x26,// Participants
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
         0x07, 0x10,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -101,10 +161,19 @@
   BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock1), ChatroomInfo::Error);
 
   const uint8_t error2[] = {
-    0x81, 0x2d, // ChatroomInfo
-      0x81, 0x01, // Wrong TrustModel Type (0x82, 0x01)
+    0x80, 0x5d, // ChatroomInfo
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
+      0x83, 0x01, // TrustModel Type Error
         0x01,
-      0x80, 0x14,// Participant1
+      0x83, 0x12, // ChatroomPrefix
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+      0x84, 0x14, // ManagerPrefix
         0x07, 0x12,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -112,7 +181,14 @@
             0x75, 0x63, 0x6c, 0x61,
           0x08, 0x05,
             0x61, 0x6c, 0x69, 0x63, 0x65,
-      0x80, 0x12, // Participant2
+      0x85, 0x26,// Participants
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
         0x07, 0x10,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -126,10 +202,19 @@
   BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock2), ChatroomInfo::Error);
 
   const uint8_t error3[] = {
-    0x81, 0x2d, // ChatroomInfo
+    0x80, 0x5d, // ChatroomInfo
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
       0x82, 0x01, // TrustModel
         0x01,
-      0x80, 0x14,// Participant1
+      0x80, 0x12, // ChatroomPrefix Type Error
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+      0x84, 0x14, // ManagerPrefix
         0x07, 0x12,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -137,7 +222,14 @@
             0x75, 0x63, 0x6c, 0x61,
           0x08, 0x05,
             0x61, 0x6c, 0x69, 0x63, 0x65,
-      0x81, 0x12, // Wrong Participant Type (0x80, 0x12)
+      0x85, 0x26,// Participants
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
         0x07, 0x10,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -151,25 +243,116 @@
   BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock3), ChatroomInfo::Error);
 
   const uint8_t error4[] = {
-    0x81, 0x00 // Empty ChatroomInfo
+    0x80, 0x5d, // ChatroomInfo
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
+      0x82, 0x01, // TrustModel
+        0x01,
+      0x83, 0x12, // ChatroomPrefix
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+      0x80, 0x14, // ManagerPrefix Error Type
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
+      0x85, 0x26,// Participants
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x03,
+            0x79, 0x6d, 0x6a
   };
 
   Block errorBlock4(error4, sizeof(error4));
   BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock4), ChatroomInfo::Error);
 
   const uint8_t error5[] = {
-    0x81, 0x03, // ChatroomInfo
+    0x80, 0x5d, // ChatroomInfo
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
       0x82, 0x01, // TrustModel
-        0x01
-    //zero Participant
+        0x01,
+      0x83, 0x12, // ChatroomPrefix
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+      0x84, 0x14, // ManagerPrefix
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
+      0x80, 0x26,// Participants Error Type
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x03,
+            0x79, 0x6d, 0x6a
   };
 
   Block errorBlock5(error5, sizeof(error5));
   BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock5), ChatroomInfo::Error);
+
+  const uint8_t error6[] = {
+    0x80, 0x00 // Empty ChatroomInfo
+  };
+
+  Block errorBlock6(error6, sizeof(error6));
+  BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock6), ChatroomInfo::Error);
+
+  const uint8_t error7[] = {
+    0x80, 0x1f, // ChatroomInfo
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
+      0x82, 0x01, // TrustModel
+        0x01,
+      0x83, 0x12, // ChatroomPrefix
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+    // no Participant
+  };
+
+  Block errorBlock7(error7, sizeof(error7));
+  BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock7), ChatroomInfo::Error);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
 
-} //namespace test
+} // namespace test
 
-} //namespace chronos
+} // namespace chronos