登录退出完善

This commit is contained in:
1
2025-08-28 21:57:30 +00:00
parent 79361e68cd
commit 406d9129b0
4 changed files with 18 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ package socket
import (
"blazing/common/utils"
"blazing/modules/blazing/model"
"blazing/modules/blazing/service"
"context"
"fmt"
"sync"
@@ -51,6 +52,7 @@ type Player struct {
IsFighting bool
context.Context
Playerinvite uint32 //当前邀请的玩家ID
Onlinetime uint32 //当前登录时间
}
// PlayerOption 定义配置 Player 的函数类型
@@ -85,6 +87,16 @@ func (p *Player) Cheak(b error) {
}
// Save 保存玩家数据
func (p *Player) Save() {
p.Info.TimeToday = p.Info.TimeToday + uint32(time.Now().Unix()) - uint32(p.Onlinetime) //保存电池时间
p.Onlinetime = uint32(time.Now().Unix())
service.NewUserService(p.Info.UserID).Save(p.Info)
}
// IsLoggedIn 检查是否已登录
func (lw *Player) IsLoggedIn() bool {
lw.mu.Lock()