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>
|
2025-05-10 14:48:42 +08:00
|
|
|
#include <cstdint>
|
2025-05-10 01:25:02 +08:00
|
|
|
|
2025-05-11 00:32:52 +08:00
|
|
|
// 这里规定,前 30 个内容(包含)为与服务端交流用。
|
|
|
|
// 大于 30 的内容仅做转发。
|
2025-05-10 21:43:25 +08:00
|
|
|
enum FrameBufferType : uint16_t {
|
2025-05-11 00:32:52 +08:00
|
|
|
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 {
|
2025-05-10 14:48:42 +08:00
|
|
|
FrameBuffer();
|
2025-05-10 01:25:02 +08:00
|
|
|
~FrameBuffer();
|
2025-05-10 21:43:25 +08:00
|
|
|
|
2025-05-11 21:27:59 +08:00
|
|
|
int32_t len{};
|
2025-05-10 21:43:25 +08:00
|
|
|
char* dataMut;
|
2025-05-10 01:25:02 +08:00
|
|
|
std::string fid;
|
|
|
|
std::string tid;
|
2025-05-10 14:48:42 +08:00
|
|
|
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);
|
2025-05-11 21:27:59 +08:00
|
|
|
static bool PackBuffer(FrameBuffer* frame, char** buf, int32_t& len);
|
2025-05-05 23:22:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // COMMUNICATE_H
|