#pragma once

#include "../../core/net/Context.hpp"

#include <functional>

namespace net::client {

enum queue: uint8_t {
    GLOBAL = 0,
    MOVE,
    count
};

/// Network client
class Client final: public Context, public Connection {
public:
    Client(const address& ct,
        std::function<bool(const data::out_view&, PacketFlags)> onPacket);
    ~Client();

    bool isRunning() const override { return !disconnected; }

    /// Read-write on sockets and notify callbacks
    void pull() { Context::pull(1000, 50, 20); }

    int connectionCallback(uint64_t stream_id, uint8_t *bytes, size_t length,
        picoquic_call_back_event_t fin_or_event, void *v_stream_ctx);

private:
    bool connected = false;
    bool disconnected = false;

    std::function<bool(const data::out_view&, PacketFlags)> onPacket;
};

}