#pragma once
#include <myapp/rcon/peerprovider.h>
#include <myapp/logging/logger.h>
#include <memory>
#include <string>

namespace myapp::rcon {

class client final
{
public:
    explicit client(std::shared_ptr<logging::logger>, std::unique_ptr<peer_provider>);
    void connect(std::string endpoint);
    void write(std::string);
    void set_on_data(std::function<void(std::string)>) noexcept;
    void set_on_connected(std::function<void()>) noexcept;
    void set_on_closed(std::function<void()>) noexcept;

private:
    void on_data(std::string);
    void on_closed();
    void on_connected(std::unique_ptr<connection>);
    void on_error(std::string);

private:
    std::shared_ptr<logging::logger> logger_;
    std::unique_ptr<peer_provider> peerProvider_;
    std::unique_ptr<connection> connection_;
    std::function<void(std::string)> data_handler_;
    std::function<void()> connected_handler_;
    std::function<void()> closed_handler_;
};

} /* namespace myapp::rcon */
