```
refactor(socket): 优化TCP数据包处理逻辑并增加调试日志 - 修复 handleTcp 中条件判断的空格格式问题 - 在解码失败时增加详细 Debug 日志输出 - 完善不完整数据包时手动唤醒连接的处理流程 refactor(pet): 重构宠物经验系统与升级逻辑 - 将经验计算函数移至 model 层统一管理 - 优化 AddPetExp 方法逻辑,避免直接修改原字段 - 升级过程中正确扣减经验池并防止溢出 - 抽离 Update 方法用于处理宠物进化和经验更新 refactor(model): 调整 PlayerInfo 结构体引用方式及相关初始化逻辑 - 修改
This commit is contained in:
@@ -156,7 +156,7 @@ func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) {
|
||||
data, err := s.codec.Decode(conn)
|
||||
if err != nil {
|
||||
|
||||
if err == codec.ErrIncompletePacket&&conn.InboundBuffered()>0 {
|
||||
if err == codec.ErrIncompletePacket && conn.InboundBuffered() > 0 {
|
||||
t, _ := conn.Peek(conn.InboundBuffered())
|
||||
cool.Loger.Debug(context.Background(), "断包", err.Error(), conn.InboundBuffered(), t)
|
||||
if err := conn.Wake(nil); err != nil { // wake up the connection manually to avoid missing the leftover data
|
||||
@@ -164,6 +164,7 @@ func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) {
|
||||
return gnet.Close
|
||||
}
|
||||
} else {
|
||||
cool.Loger.Debug(context.Background(), "数据错误", err.Error(), conn.InboundBuffered())
|
||||
action = gnet.Close
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user