reduce heart-beat interval
diff --git a/chatdialog.cpp b/chatdialog.cpp
index 5dad227..845ccfb 100644
--- a/chatdialog.cpp
+++ b/chatdialog.cpp
@@ -16,7 +16,7 @@
#define DEFAULT_LOCAL_PREFIX "/private/local"
#define CCN_EXEC "/usr/local/bin/ccnpeek"
-static const int HELLO_INTERVAL = 90; // seconds
+static const int HELLO_INTERVAL = FRESHNESS * 3 / 4; // seconds
ChatDialog::ChatDialog(QWidget *parent)
: QDialog(parent), m_sock(NULL), m_lastMsgTime(0), m_historyInitialized(false)
@@ -27,9 +27,6 @@
qRegisterMetaType<size_t>("size_t");
setupUi(this);
m_session = time(NULL);
- boost::random::random_device rng;
- boost::random::uniform_int_distribution<> uniform(1, 29000);
- m_randomizedInterval = HELLO_INTERVAL * 1000 + uniform(rng);
readSettings();
@@ -79,7 +76,7 @@
QTimer::singleShot(100, this, SLOT(getLocalPrefix()));
QTimer::singleShot(600, this, SLOT(sendJoin()));
- m_timer->start(FRESHNESS * 2000);
+ m_timer->start(FRESHNESS);
disableTreeDisplay();
QTimer::singleShot(2200, this, SLOT(enableTreeDisplay()));
}
@@ -718,6 +715,9 @@
SyncDemo::ChatMessage msg;
formControlMessage(msg, SyncDemo::ChatMessage::JOIN);
sendMsg(msg);
+ boost::random::random_device rng;
+ boost::random::uniform_int_distribution<> uniform(1, FRESHNESS / 5 * 1000);
+ m_randomizedInterval = HELLO_INTERVAL * 1000 + uniform(rng);
QTimer::singleShot(m_randomizedInterval, this, SLOT(sendHello()));
}
@@ -731,6 +731,9 @@
SyncDemo::ChatMessage msg;
formControlMessage(msg, SyncDemo::ChatMessage::HELLO);
sendMsg(msg);
+ boost::random::random_device rng;
+ boost::random::uniform_int_distribution<> uniform(1, FRESHNESS / 5 * 1000);
+ m_randomizedInterval = HELLO_INTERVAL * 1000 + uniform(rng);
QTimer::singleShot(m_randomizedInterval, this, SLOT(sendHello()));
}
else
@@ -845,7 +848,7 @@
Sync::CcnxWrapperPtr handle = Sync::CcnxWrapper::Create();
handle->setInterestFilter(m_user.getPrefix().toStdString(), bind(&ChatDialog::respondHistoryRequest, this, _1));
QTimer::singleShot(1000, this, SLOT(sendJoin()));
- m_timer->start(FRESHNESS * 2000);
+ m_timer->start(FRESHNESS);
disableTreeDisplay();
QTimer::singleShot(2200, this, SLOT(enableTreeDisplay()));
}
diff --git a/digesttreescene.cpp b/digesttreescene.cpp
index 79f5fe6..64f6949 100644
--- a/digesttreescene.cpp
+++ b/digesttreescene.cpp
@@ -28,7 +28,7 @@
{
rePlot = true;
DisplayUserPtr p(new DisplayUser());
- time_t tempTime = time(NULL) - 2 * FRESHNESS + 1;
+ time_t tempTime = time(NULL) - FRESHNESS + 1;
p->setReceived(tempTime);
p->setPrefix(v[i].prefix.c_str());
p->setSeq(v[i].high);
@@ -156,7 +156,7 @@
if (p != DisplayUserNullPtr)
{
time_t now = time(NULL);
- if (now - p->getReceived() >= FRESHNESS * 2)
+ if (now - p->getReceived() >= FRESHNESS)
{
#ifdef __DEBUG
std::cout << "Removing user: " << p->getNick().toStdString() << std::endl;
diff --git a/digesttreescene.h b/digesttreescene.h
index 33a4973..29d9177 100644
--- a/digesttreescene.h
+++ b/digesttreescene.h
@@ -11,7 +11,7 @@
#include <QColor>
#include "treelayout.h"
-const int FRESHNESS = 120;
+const int FRESHNESS = 60;
class QGraphicsTextItem;