Esempio n. 1
0
void
Chat::sendMessage(const string& chatMessage)
{
  if (messageCache_.size() == 0)
    messageCacheAppend(SyncDemo::ChatMessage_ChatMessageType_JOIN, "xxx");

  // Ignore an empty message.
  // forming Sync Data Packet.
  if (chatMessage != "") {
    sync_->publishNextSequenceNo();
    messageCacheAppend(SyncDemo::ChatMessage_ChatMessageType_CHAT, chatMessage);
    cout << screenName_ << ": " << chatMessage << endl;
  }
}
Esempio n. 2
0
void
Chat::heartbeat(const ptr_lib::shared_ptr<const Interest> &interest)
{
  if (messageCache_.size() == 0)
    messageCacheAppend(SyncDemo::ChatMessage_ChatMessageType_JOIN, "xxx");

  sync_->publishNextSequenceNo();
  messageCacheAppend(SyncDemo::ChatMessage_ChatMessageType_HELLO, "xxx");

  // Call again.
  // TODO: Are we sure using a "/local/timeout" interest is the best future call approach?
  Interest timeout("/local/timeout");
  timeout.setInterestLifetimeMilliseconds(60000);
  face_.expressInterest(timeout, dummyOnData, bind(&Chat::heartbeat, shared_from_this(), _1));
}
Esempio n. 3
0
void
Chat::leave()
{
  sync_->publishNextSequenceNo();
  messageCacheAppend(SyncDemo::ChatMessage_ChatMessageType_LEAVE, "xxx");
}