``feat(socket): 完善踢人流程日志记录,添加CloseChan确保数据保存完成``
This commit is contained in:
@@ -42,6 +42,7 @@ func (s *Server) Stop() error {
|
||||
}
|
||||
|
||||
func (s *Server) OnClose(c gnet.Conn, _ error) (action gnet.Action) {
|
||||
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
fmt.Println("Recovered in f", r)
|
||||
@@ -52,8 +53,13 @@ func (s *Server) OnClose(c gnet.Conn, _ error) (action gnet.Action) {
|
||||
v, ok := c.Context().(*player.ClientData)
|
||||
|
||||
if ok && v.Player != nil {
|
||||
|
||||
cool.Loger.Info(context.TODO(), "准备保存", v.Player.Info.UserID)
|
||||
v.Player.Save() //保存玩家数据
|
||||
cool.Loger.Info(context.TODO(), "保存完成", v.Player.Info.UserID)
|
||||
if v.CloseChan != nil {
|
||||
close(v.CloseChan)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user