Merge branch 'main' of https://cnb.cool/blzing/blazing
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -55,8 +55,19 @@ func (s *Server) OnClose(c gnet.Conn, err error) (action gnet.Action) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值
|
||||
// 1. 打印错误信息
|
||||
if t, ok := c.Context().(*player.ClientData); ok {
|
||||
if t.Player != nil {
|
||||
if t.Player.Info != nil {
|
||||
cool.Logger.Error(context.TODO(), "OnClose 错误:", t.Player.Info.UserID, err)
|
||||
t.Player.Service.Info.Save(*t.Player.Info)
|
||||
}
|
||||
|
||||
fmt.Println(context.TODO(), "panic 错误:", err)
|
||||
}
|
||||
|
||||
} else {
|
||||
cool.Logger.Error(context.TODO(), "OnClose 错误:", err)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}()
|
||||
@@ -121,7 +132,9 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
||||
if t, ok := c.Context().(*player.ClientData); ok {
|
||||
if t.Player != nil {
|
||||
if t.Player.Info != nil {
|
||||
cool.Logger.Error(context.TODO(), "panic 错误:", t.Player.Info.UserID, err)
|
||||
cool.Logger.Error(context.TODO(), "OnTraffic 错误:", t.Player.Info.UserID, err)
|
||||
t.Player.Service.Info.Save(*t.Player.Info)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -262,11 +275,10 @@ func (s *Server) onevent(c gnet.Conn, v []byte) {
|
||||
// 解析Result(13-16字节)
|
||||
//header.Result = binary.BigEndian.Uint32(v[13:17])
|
||||
// 解析数据部分(17字节之后)
|
||||
header.Data = make([]byte, 0)
|
||||
if len(v) > 17 {
|
||||
header.Data = v[17:]
|
||||
|
||||
} else {
|
||||
header.Data = []byte{} // 数据部分为空时显式初始化
|
||||
}
|
||||
if header.CMD > 1001 {
|
||||
if t.Player == nil {
|
||||
@@ -287,9 +299,6 @@ func (s *Server) onevent(c gnet.Conn, v []byte) {
|
||||
}
|
||||
|
||||
t.LF.Producer().Write(header)
|
||||
// s.workerPool.Submit(func() { //提交任务
|
||||
// t.OnEvent(data)
|
||||
// })
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user