refactor(socket): 使用fmt.Println替换Logger.Error处理panic

修复socket连接关闭和流量处理中的panic恢复机制,
使用fmt.Println直接打印错误信息替代原有的Logger组件。

---

refactor(timer): 移除ants协程池依赖并优化错误处理

移除timer模块中对ants协程池的依赖,改用原生goroutine,
添加panic恢复机制确保任务执行的稳定性。

---

feat(player): 移除CountPlayer函数

删除玩家服务中统计在线玩家数量的功能函数,
该功能
This commit is contained in:
昔念
2026-01-29 01:13:32 +08:00
parent e37d5a4d80
commit 40b4d5955e
4 changed files with 23 additions and 33 deletions

View File

@@ -2,6 +2,7 @@ package socket
import (
"context"
"fmt"
"log"
"os"
"sync/atomic"
@@ -44,7 +45,7 @@ func (s *Server) OnClose(c gnet.Conn, err error) (action gnet.Action) {
if err := recover(); err != nil { // 恢复 panicerr 为 panic 错误值
// 1. 打印错误信息
cool.Logger.Error(context.TODO(), "panic 错误:", err)
fmt.Println(context.TODO(), "panic 错误:", err)
}
}()
@@ -111,7 +112,7 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
if err := recover(); err != nil { // 恢复 panicerr 为 panic 错误值
// 1. 打印错误信息
cool.Logger.Error(context.TODO(), "panic 错误:", err)
fmt.Println(context.TODO(), "panic 错误:", err)
}
}()