feat: 协议消息类型改名,为以后更多服务器命令做预留
This commit is contained in:
parent
c05c02c098
commit
735ead43b5
|
|
@ -532,7 +532,7 @@ static void* response_listener_thread(void* arg) {
|
|||
}
|
||||
|
||||
/* 处理服务端响应 */
|
||||
if (msg_type == MSG_TYPE_SERVER_RESPONSE && payload != NULL) {
|
||||
if (msg_type == MSG_TYPE_SERVER_RENDER && payload != NULL) {
|
||||
ssize_t written = write(*output_fd, payload, payload_len);
|
||||
if (written < 0) {
|
||||
DEBUG_LOG("写入输出失败: %s", strerror(errno));
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
typedef enum {
|
||||
MSG_TYPE_INIT = 1, // 初始化连接,发送命令信息
|
||||
MSG_TYPE_WINDOW_SIZE_UPDATE = 2, // 终端窗口大小更新
|
||||
MSG_TYPE_SERVER_RESPONSE = 3, // 服务器响应消息
|
||||
MSG_TYPE_SERVER_RENDER = 3, // 服务器渲染消息
|
||||
MSG_TYPE_CLOSE = 4, // 关闭连接
|
||||
MSG_TYPE_TERMINAL_INPUT = 5, // 终端输入数据(键盘、鼠标等)
|
||||
MSG_TYPE_TERMINAL_OUTPUT = 6, // 终端输出数据
|
||||
|
|
@ -37,7 +37,8 @@ typedef struct {
|
|||
// 从 reserved 字段提取压缩标志和原始大小
|
||||
#define GET_COMPRESS_FLAGS(reserved) ((reserved) & 0xFFFF)
|
||||
#define GET_ORIGINAL_SIZE_HINT(reserved) (((reserved) >> 16) * 256)
|
||||
#define MAKE_RESERVED(flags, orig_size) (((flags) & 0xFFFF) | (((orig_size) / 256) << 16))
|
||||
#define MAKE_RESERVED(flags, orig_size) \
|
||||
(((flags) & 0xFFFF) | (((orig_size) / 256) << 16))
|
||||
|
||||
// 终端信息结构
|
||||
typedef struct {
|
||||
|
|
@ -89,7 +90,8 @@ typedef struct {
|
|||
} ProtocolContext;
|
||||
|
||||
// 初始化协议上下文
|
||||
void protocol_init(ProtocolContext* ctx, CompressionType compress_type, int compress_level);
|
||||
void protocol_init(ProtocolContext* ctx, CompressionType compress_type,
|
||||
int compress_level);
|
||||
|
||||
// 带压缩支持的消息读写
|
||||
int write_message_compressed(int sock, ProtocolContext* ctx, MessageType type,
|
||||
|
|
@ -99,8 +101,10 @@ int read_message_decompressed(int sock, MessageType* type, void** payload,
|
|||
#endif
|
||||
|
||||
// 函数声明
|
||||
int write_message(int sock, MessageType type, const void* payload, uint32_t payload_len);
|
||||
int read_message(int sock, MessageType* type, void** payload, uint32_t* payload_len);
|
||||
int write_message(int sock, MessageType type, const void* payload,
|
||||
uint32_t payload_len);
|
||||
int read_message(int sock, MessageType* type, void** payload,
|
||||
uint32_t* payload_len);
|
||||
|
||||
void free_message_payload(void* payload);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue