#pragma once

#include "ros_bridge/include/ComPrivateInclude.h"
#include "ros_bridge/include/RosBridgeClient.h"
#include "ros_bridge/include/TypeFactory.h"
#include "ros_bridge/include/CasePacker.h"

namespace ROSBridge {
namespace ComPrivate {

class Server
{
    typedef std::vector<std::string> ClientList;
public:
    typedef std::function<JsonDocUPtr(JsonDocUPtr)> CallbackType;


    Server() = delete;
    Server(CasePacker &casePacker, RosbridgeWsClient &rbc);
    ~Server();

    //! @brief Starts the subscriber.
    void start();

    //! @brief Resets the subscriber.
    void reset();

    void advertiseService(const std::string& service,
                          const std::string& type,
                          const CallbackType& userCallback);

private:

    RosbridgeWsClient  &_rbc;
    CasePacker         &_casePacker;
    ClientList          _clientList;
    bool                _running;
};
} // namespace ComPrivate
} // namespace ROSBridge
