/*
 * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>,
 * released under GNU AGPL v3 license:
 * https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
 */

#ifndef MOONWELL_PLAYER_GUIDE_TRANSPORT_H
#define MOONWELL_PLAYER_GUIDE_TRANSPORT_H

#include "Define.h"

#include <string>
#include <string_view>

class Player;

namespace MoonWell::PlayerGuide
{
    // Addon channel prefix used on both ends. The client AIO bridge
    // routes messages with this prefix to the MoonWellPlayerGuide
    // handler.
    constexpr char const* ADDON_PREFIX = "MWPG";

    // Commands sent server -> client.
    namespace ServerCmd
    {
        constexpr char const* SET_DATA         = "SetData";
        constexpr char const* SET_STAGE        = "SetStage";
        constexpr char const* UPDATE_OBJECTIVE = "UpdateObjective";
        constexpr char const* NOTIFY           = "Notify";
    }

    // Commands sent client -> server.
    namespace ClientCmd
    {
        constexpr char const* REQUEST_REFRESH          = "RequestRefresh";
        constexpr char const* REQUEST_TRACK_OBJECTIVE  = "RequestTrackObjective";
        constexpr char const* REQUEST_OPEN_TARGET      = "RequestOpenTarget";
    }

    class Transport
    {
    public:
        // Sends a single logical message split into addon-channel
        // chunks. Wire format per chunk:
        //   "MWPG\t<cmd>\t<seq>\t<total>\t<body>"
        // Single-chunk messages still use seq=1 total=1.
        static void Send(Player* player, std::string_view command,
                         std::string_view body);

        // Convenience wrappers.
        static void SendSetData(Player* player, std::string const& json);
        static void SendNotify(Player* player, std::string const& text);
    };
}

#endif // MOONWELL_PLAYER_GUIDE_TRANSPORT_H
