diff --git a/demo/chatdialog.cpp b/demo/chatdialog.cpp
index 6fd93df..10c7af0 100644
--- a/demo/chatdialog.cpp
+++ b/demo/chatdialog.cpp
@@ -5,26 +5,47 @@
 #include <iostream>
 #include <QTimer>
 
+#define BROADCAST_PREFIX_FOR_SYNC_DEMO "/ndn/broadcast/sync-demo"
+
 ChatDialog::ChatDialog(QWidget *parent)
-  : QDialog(parent)
+  : QDialog(parent), m_sock(NULL)
 {
   setupUi(this);
+  m_session = time(NULL);
 
   readSettings();
+
   updateLabels();
 
   lineEdit->setFocusPolicy(Qt::StrongFocus);
-  DigestTreeScene *scene = new DigestTreeScene();
+  m_scene = new DigestTreeScene(this);
 
-  treeViewer->setScene(scene);
-  QRectF rect = scene->itemsBoundingRect();
-  scene->setSceneRect(rect);
-  //scene->plot();
+  treeViewer->setScene(m_scene);
+  m_scene->plot("Empty");
+  QRectF rect = m_scene->itemsBoundingRect();
+  m_scene->setSceneRect(rect);
+
+  // create sync socket
+  if(!m_user.getChatroom().isEmpty()) {
+    std::string syncPrefix = BROADCAST_PREFIX_FOR_SYNC_DEMO;
+    syncPrefix += "/";
+    syncPrefix += m_user.getChatroom().toStdString();
+    m_sock = new Sync::SyncAppSocket(syncPrefix, bind(&ChatDialog::processTreeUpdate, this, _1, _2), bind(&ChatDialog::processRemove, this, _1));
+  }
 
   connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
   connect(setButton, SIGNAL(pressed()), this, SLOT(buttonPressed()));
 }
 
+ChatDialog::~ChatDialog()
+{
+  if (m_sock != NULL) 
+  {
+    delete m_sock;
+    m_sock = NULL;
+  }
+}
+
 void
 ChatDialog::appendMessage(const SyncDemo::ChatMessage &msg) 
 {
@@ -54,15 +75,79 @@
 }
 
 void
+ChatDialog::processTreeUpdate(const std::vector<Sync::MissingDataInfo> &v, Sync::SyncAppSocket *)
+{
+  if (v.empty())
+  {
+    return;
+  }
+
+  // reflect the changes on digest tree
+  m_scene->processUpdate(v, m_sock->getRootDigest().c_str());
+
+  int n = v.size();
+  int totalMissingPackets = 0;
+  for (int i = 0; i < n; i++) 
+  {
+    totalMissingPackets += v[i].high.getSeq() - v[i].low.getSeq() + 1;
+  }
+  
+  if (totalMissingPackets < 10) {
+    for (int i = 0; i < n; i++) 
+    {
+      for (Sync::SeqNo seq = v[i].low; seq <= v[i].high; ++seq)
+      {
+        m_sock->fetchRaw(v[i].prefix, seq, bind(&ChatDialog::processData, this, _1, _2, _3), 2);
+      }
+    }
+  }
+  else
+  {
+    // too bad; too many missing packets
+    // we may just join a new chatroom
+    // or some network patition just healed
+    // we don't try to fetch any data in this case (for now)
+  }
+
+  // adjust the view
+  fitView();
+
+}
+
+void
+ChatDialog::processData(std::string name, const char *buf, size_t len)
+{
+  SyncDemo::ChatMessage msg;
+  if (!msg.ParseFromArray(buf, len)) 
+  {
+    std::cerr << "Errrrr.. Can not parse msg at "<<__FILE__ <<":"<<__LINE__<<". what is happening?" << std::endl;
+    abort();
+  }
+
+  // display
+  appendMessage(msg);
+  
+  // update the tree view
+  std::string prefix = name.substr(0, name.find_last_of('/'));
+  m_scene->msgReceived(prefix.c_str(), msg.from().c_str());
+}
+
+void
+ChatDialog::processRemove(std::string prefix)
+{
+}
+
+void
 ChatDialog::formChatMessage(const QString &text, SyncDemo::ChatMessage &msg) {
   msg.set_from(m_user.getNick().toStdString());
   msg.set_to(m_user.getChatroom().toStdString());
   msg.set_data(text.toStdString());
   time_t seconds = time(NULL);
   msg.set_timestamp(seconds);
+  msg.set_type(SyncDemo::ChatMessage::CHAT);
 }
 
-void
+bool
 ChatDialog::readSettings()
 {
   QSettings s(ORGANIZATION, APPLICATION);
@@ -71,11 +156,13 @@
   QString prefix = s.value("prefix", "").toString();
   if (nick == "" || chatroom == "" || prefix == "") {
     QTimer::singleShot(500, this, SLOT(buttonPressed()));
+    return false;
   }
   else {
     m_user.setNick(nick);
     m_user.setChatroom(chatroom);
     m_user.setPrefix(prefix);
+    return true;
   }
 }
 
@@ -109,9 +196,18 @@
   SyncDemo::ChatMessage msg;
   formChatMessage(text, msg);
   
-  // TODO:
-  // send message
   appendMessage(msg);
+
+  // send msg
+  size_t size = msg.ByteSize();
+  char *buf = new char[size];
+  msg.SerializeToArray(buf, size);
+  if (!msg.IsInitialized()) 
+  {
+    std::cerr << "Errrrr.. msg was not probally initialized "<<__FILE__ <<":"<<__LINE__<<". what is happening?" << std::endl;
+    abort();
+  }
+  m_sock->publishRaw(m_user.getPrefix().toStdString(), m_session, buf, size, 60);
   
 }
 
@@ -139,7 +235,22 @@
   if (!chatroom.isEmpty() && chatroom != m_user.getChatroom()) {
     m_user.setChatroom(chatroom);
     needWrite = true;
+
+    m_scene->clearAll();
+    m_scene->plot("Empty");
     // TODO: perhaps need to do a lot. e.g. use a new SyncAppSokcet
+    if (m_sock != NULL) 
+    {
+      delete m_sock;
+      m_sock = NULL;
+    }
+    std::string syncPrefix = BROADCAST_PREFIX_FOR_SYNC_DEMO;
+    syncPrefix += "/";
+    syncPrefix += m_user.getChatroom().toStdString();
+    m_sock = new Sync::SyncAppSocket(syncPrefix, bind(&ChatDialog::processTreeUpdate, this, _1, _2), bind(&ChatDialog::processRemove, this, _1));
+
+    fitView();
+    
   }
   if (needWrite) {
     writeSettings();
@@ -162,5 +273,5 @@
 void
 ChatDialog::fitView()
 {
-  treeViewer->fitInView(treeViewer->scene()->itemsBoundingRect(), Qt::KeepAspectRatio);
+  treeViewer->fitInView(m_scene->itemsBoundingRect(), Qt::KeepAspectRatio);
 }
