feat(socket): 优化服务器事件处理逻辑并修复数据解码问题

- 移除重复的 `gnet.WithTicker(true)` 配置项
- 调整 `OnTick` 的执行间隔从 10 秒延长至 30 秒
- 更新 `NewClientData` 方法以传入连接对象,用于后续消息处理
- 将 `c.Read` 替换为 `c.Discard` 以正确丢弃已读数据
- 改进数据包处理逻辑,增强对不完整包的处理能力
- 修正 `TomeeHeader.Version` 类型由 string 转为 byte,并更新相关读写操作
- 在消息处理中增加错误日志打印
This commit is contained in:
2025-10-28 02:28:15 +08:00
parent d1b2f8844a
commit ec082db71d
6 changed files with 58 additions and 53 deletions

View File

@@ -1,6 +1,8 @@
package codec
import (
"blazing/cool"
"context"
"encoding/binary"
"errors"
"io"
@@ -58,6 +60,7 @@ func (codec TomeeSocketCodec) Decode(c gnet.Conn) ([]byte, error) {
}
bodyLen := binary.BigEndian.Uint32(lenBuf)
cool.Loger.Print(context.TODO(), "lenBuf", bodyLen)
if bodyLen > maxBodyLen {
return nil, errors.New("packet body exceeds max length")
}