#pragma once
#include <myapp/rcon/connection.h>
#include <myapp/async/pipe.h>
#include <memory>

namespace myapp::rcon {

class unix_connection final : public connection
{
public:
    explicit unix_connection(std::unique_ptr<async::pipe>);
    ~unix_connection();

    void write(std::string) override;
    void on_data(std::function<void(std::string)>) noexcept override;
    void on_peer_closed(std::function<void()>) noexcept override;

private:
    std::unique_ptr<async::pipe> pipe_;
    std::function<void(std::string)> data_handler_;
    std::function<void()> closed_handler_;
};

} /* namespace myapp::rcon */
