diff --git a/chatdialog.cpp b/chatdialog.cpp
index 6fd93df..10c7af0 100644
--- a/chatdialog.cpp
+++ b/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);
 }
