/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2014-2015,  Regents of the University of California,
 *                           Arizona Board of Regents,
 *                           Colorado State University,
 *                           University Pierre & Marie Curie, Sorbonne University,
 *                           Washington University in St. Louis,
 *                           Beijing Institute of Technology,
 *                           The University of Memphis.
 *
 * This file is part of NFD (Named Data Networking Forwarding Daemon).
 * See AUTHORS.md for complete list of NFD authors and contributors.
 *
 * NFD is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef NFD_DAEMON_FACE_WEBSOCKET_CHANNEL_HPP
#define NFD_DAEMON_FACE_WEBSOCKET_CHANNEL_HPP

#include "channel.hpp"
#include "websocketpp.hpp"

namespace nfd {

namespace websocket {
typedef boost::asio::ip::tcp::endpoint Endpoint;
} // namespace websocket

/**
 * \brief Class implementing WebSocket-based channel to create faces
 */
class WebSocketChannel : public Channel
{
public:
  /**
   * \brief Create WebSocket channel for the local endpoint
   *
   * To enable creation of faces upon incoming connections,
   * one needs to explicitly call WebSocketChannel::listen method.
   * The created channel is bound to the localEndpoint.
   */
  explicit
  WebSocketChannel(const websocket::Endpoint& localEndpoint);

  /**
   * \brief Enable listening on the local endpoint, accept connections,
   *        and create faces when remote host makes a connection
   *
   * \param onFaceCreated Callback to notify successful creation of a face
   */
  void
  listen(const FaceCreatedCallback& onFaceCreated);

  /**
   * \brief Get number of faces in the channel
   */
  size_t
  size() const;

  bool
  isListening() const;

PUBLIC_WITH_TESTS_ELSE_PRIVATE:
  /** \pre listen hasn't been invoked
   */
  void
  setPingInterval(time::milliseconds interval);

  /** \pre listen hasn't been invoked
   */
  void
  setPongTimeout(time::milliseconds timeout);

  void
  handlePong(websocketpp::connection_hdl hdl);

  void
  handlePongTimeout(websocketpp::connection_hdl hdl);

private:
  void
  handleMessage(websocketpp::connection_hdl hdl,
                websocket::Server::message_ptr msg);

  void
  handleOpen(websocketpp::connection_hdl hdl);

  void
  handleClose(websocketpp::connection_hdl hdl);

private:
  websocket::Endpoint m_localEndpoint;
  websocket::Server m_server;

  std::map<websocketpp::connection_hdl, shared_ptr<Face>,
           std::owner_less<websocketpp::connection_hdl>> m_channelFaces;

  FaceCreatedCallback m_onFaceCreatedCallback;
  time::milliseconds m_pingInterval;
};

inline bool
WebSocketChannel::isListening() const
{
  return m_server.is_listening();
}

} // namespace nfd

#endif // NFD_DAEMON_FACE_WEBSOCKET_CHANNEL_HPP
