#ifndef COMMUNICATE_H
#define COMMUNICATE_H

#include <Util.h>
#include <cstdint>

// 这里规定,前 30 个内容(包含)为与服务端交流用。
// 大于 30 的内容仅做转发。
enum FrameBufferType : uint16_t {
    FBT_SER_MSG_ASKCLIENTS = 0,
    FBT_SER_MSG_YOURID,
    FBT_SER_MSG_RESPONSE,
    FBT_CLI_BIN_FILEDATA = 31,
    FBT_CLI_MSG_COMMUNICATE,
    FBT_CLI_INFO_DIRFILE
};

struct FrameBuffer {
    FrameBuffer();
    ~FrameBuffer();

    int32_t len{};
    char* dataMut;
    std::string fid;
    std::string tid;
    const char* dataConst;
    FrameBufferType dataType{};
};

class Communicate
{
public:
    Communicate();

public:
    static FrameBuffer* ParseBuffer(MutBuffer& buffer);
    static bool PackBuffer(FrameBuffer* frame, char** buf, int32_t& len);
};

#endif   // COMMUNICATE_H