/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2014-2022,  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_TRANSPORT_HPP
#define NFD_DAEMON_FACE_WEBSOCKET_TRANSPORT_HPP

#include "transport.hpp"
#include "websocketpp.hpp"

namespace nfd::face {

/** \brief Counters provided by WebSocketTransport.
 *  \note The type name WebSocketTransportCounters is an implementation detail.
 *        Use WebSocketTransport::Counters in public API.
 */
class WebSocketTransportCounters : public virtual Transport::Counters
{
public:
  /** \brief Count of outgoing pings.
   */
  PacketCounter nOutPings;

  /** \brief Count of incoming pongs.
   */
  PacketCounter nInPongs;
};

/** \brief A Transport that communicates on a WebSocket connection.
 */
class WebSocketTransport final : public Transport
                               , protected virtual WebSocketTransportCounters
{
public:
  /** \brief %Counters provided by WebSocketTransport.
   */
  using Counters = WebSocketTransportCounters;

  WebSocketTransport(websocketpp::connection_hdl hdl,
                     websocket::Server& server,
                     time::milliseconds pingInterval);

  const Counters&
  getCounters() const final;

  /** \brief Translates a message into a Block and delivers it to the link service.
   */
  void
  receiveMessage(const std::string& msg);

  void
  handlePong();

  void
  handlePongTimeout();

protected:
  void
  doClose() final;

private:
  void
  doSend(const Block& packet) final;

  void
  schedulePing();

  void
  sendPing();

  void
  processErrorCode(const websocketpp::lib::error_code& error);

private:
  websocketpp::connection_hdl m_handle;
  websocket::Server& m_server;
  time::milliseconds m_pingInterval;
  scheduler::ScopedEventId m_pingEventId;
};

inline const WebSocketTransport::Counters&
WebSocketTransport::getCounters() const
{
  return *this;
}

} // namespace nfd::face

#endif // NFD_DAEMON_FACE_WEBSOCKET_TRANSPORT_HPP
