RelayFile/Protocol/Communicate.h

40 lines
811 B
C
Raw Normal View History

2025-05-05 23:22:43 +08:00
#ifndef COMMUNICATE_H
#define COMMUNICATE_H
2025-05-10 01:25:02 +08:00
#include <Util.h>
#include <cstdint>
2025-05-10 01:25:02 +08:00
// 这里规定,前 30 个内容(包含)为与服务端交流用。
// 大于 30 的内容仅做转发。
2025-05-10 21:43:25 +08:00
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
2025-05-10 21:43:25 +08:00
};
2025-05-10 01:25:02 +08:00
struct FrameBuffer {
FrameBuffer();
2025-05-10 01:25:02 +08:00
~FrameBuffer();
2025-05-10 21:43:25 +08:00
int len{};
char* dataMut;
2025-05-10 01:25:02 +08:00
std::string fid;
std::string tid;
const char* dataConst;
2025-05-10 21:43:25 +08:00
FrameBufferType dataType{};
2025-05-10 01:25:02 +08:00
};
2025-05-05 23:22:43 +08:00
class Communicate
{
public:
Communicate();
2025-05-10 01:25:02 +08:00
public:
static FrameBuffer* ParseBuffer(MutBuffer& buffer);
static bool PackBuffer(FrameBuffer* frame, char** buf, int& len);
2025-05-05 23:22:43 +08:00
};
#endif // COMMUNICATE_H