/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2013, Regents of the University of California
 *                     Yingdi Yu
 *
 * BSD license, See the LICENSE file for more information
 *
 * Author: Mengjin Yan <jane.yan0129@gmail.com>
 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
 */

#ifndef CHRONOCHAT_CHATROOM_DISCOVERY_LOGIC_HPP
#define CHRONOCHAT_CHATROOM_DISCOVERY_LOGIC_HPP

#include "chatroom-info.hpp"
#include <ndn-cxx/util/scheduler.hpp>

namespace chronos {

class ChatroomDiscoveryLogic : noncopyable
{
public:
  typedef function<void(const ChatroomInfo& chatroomName, bool isAdd)> UpdateCallback;

  typedef std::map<Name::Component, chronos::ChatroomInfo> Chatrooms;
  static const size_t OFFSET_CHATROOM_NAME;
  static const size_t DISCOVERY_INTEREST_NAME_SIZE;
  static const size_t REFRESHING_INTEREST_NAME_SIZE;
  static const time::milliseconds DEFAULT_REFRESHING_TIMER;
  static const Name DISCOVERY_PREFIX;

public:
  explicit
  ChatroomDiscoveryLogic(shared_ptr<ndn::Face> face,
                         const UpdateCallback& updateCallback);


  /** \brief obtain the ongoing chatroom list
   */
  const Chatrooms&
  getChatrooms() const;

  /** \brief add a local chatroom in the ongoing chatroom list
   */
  void
  addLocalChatroom(const ChatroomInfo& chatroom);

  void
  removeLocalChatroom(const Name::Component& chatroomName);

  /** \brief send discovery interest
   */
  void
  sendDiscoveryInterest();

CHRONOCHAT_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
  /**
   */
  void
  onDiscoveryInterest(const Name& name, const Interest& interest);

  /**
   */
  void
  onPrefixRegistrationFailed(const Name& name);

  /** \brief schedule another discovery
   */
  void
  onDiscoveryInterestTimeout(const Interest& interest);

  /** \brief send interest to find if the certain chatroom exists
   */
  void
  refreshChatroom(const Name::Component& chatroomName);

  /** \brief copy the contact from the participants of the chatroom to contacts of the chatroom
   */
  void
  addContacts(ChatroomInfo& chatroom);

CHRONOCHAT_PUBLIC_WITH_TESTS_ELSE_PRIVATE:

  /** \brief erase the chatroom from the ongoing chatroom list
   */
  void
  onRefreshingInterestTimeout(const Interest& interest);

  /** \brief operate the chatroom data and schedule discovery and refreshing process
   */
  void
  onReceiveData(const ndn::Interest& interest, const ndn::Data& data, const bool isRefreshing);

private:
  static const time::seconds m_discoveryInterval;

  shared_ptr<ndn::Face> m_face;

  ndn::KeyChain m_keyChain;

  Chatrooms m_chatrooms;
  Chatrooms m_localChatrooms;

  ndn::Scheduler m_scheduler;

  UpdateCallback m_onUpdate;

};

inline const ChatroomDiscoveryLogic::Chatrooms&
ChatroomDiscoveryLogic::getChatrooms() const
{
  return m_chatrooms;
}

} // namespace chronos

#endif // CHRONOCHAT_CHATROOM_DISCOVERY_LOGIC_HPP
