no message

This commit is contained in:
sk 2024-11-14 15:23:40 +08:00
parent 3bcc944417
commit dfe093b03e
3 changed files with 34 additions and 11 deletions

View File

@ -2,15 +2,17 @@ package main
import (
"fmt"
"mongo.games.com/goserver/core/logger"
"time"
"mongo.games.com/game/common"
"mongo.games.com/game/model"
"mongo.games.com/goserver/core/basic"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/module"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/core/task"
"mongo.games.com/game/common"
"mongo.games.com/game/model"
"mongo.games.com/game/worldsrv/internal"
)
const (
@ -236,6 +238,7 @@ func (this *LoginStateMgr) LogoutAllBySession(session *netlib.Session) {
p := PlayerMgrSington.GetOnlinePlayer(sid)
if p != nil {
p.DropLine()
internal.FirePlayerDropLine[*Player, *Scene](p)
}
}
}

View File

@ -86,6 +86,7 @@ type Player struct {
changeIconTime time.Time //上次修改头像时间
enterts time.Time //进入时间
lastChangeScene time.Time //上次换桌时间
dropTime time.Time // 掉线时间
isAudience bool //是否是观众
customerToken string //客服会话token
isDelete bool //是否已删档用户
@ -1155,6 +1156,7 @@ func (this *Player) Kick(reason int32) {
LoginStateMgrSington.LogoutBySid(this.sid)
this.DropLine()
internal.FirePlayerDropLine[*Player, *Scene](this)
}
TournamentMgr.ForceQuit(this.Platform, this.SnId)
}
@ -1632,10 +1634,19 @@ func (this *Player) OnSecTimer() {
}
func (this *Player) OnMiniTimer() {
TaskSubjectSingleton.Touch(common.TaskTypeOnlineTs, &TaskData{
SnId: this.SnId,
Num: 60,
})
if this.IsOnLine() {
TaskSubjectSingleton.Touch(common.TaskTypeOnlineTs, &TaskData{
SnId: this.SnId,
Num: 60,
})
}
// 长时间掉线又没有删除缓存
if !this.dropTime.IsZero() && time.Now().Sub(this.dropTime).Minutes() > 20 {
logger.Logger.Errorf("清除缓存异常玩家 snid:%v dirty:%v lastLogoutTime:%v lastGameId:%v", this.SnId, this.dirty, this.LastLogoutTime, this.LastGameId)
if this.scene != nil {
logger.Logger.Errorf("清除缓存异常玩家 sceneId:%v", this.scene.sceneId)
}
}
}
func (this *Player) OnHourTimer() {
@ -3884,10 +3895,12 @@ func (this *Player) SCDataConfig(tp int) {
func init() {
internal.RegisterPlayerListenerFunc(&internal.PlayerListenerFunc[*Player, *Scene]{
ClockFunc: common.ClockFunc{},
OnPlayerLoginedFunc: nil,
OnPlayerLogoutedFunc: nil,
OnPlayerDropLineFunc: nil,
ClockFunc: common.ClockFunc{},
OnPlayerLoginedFunc: nil,
OnPlayerLogoutedFunc: nil,
OnPlayerDropLineFunc: func(p *Player) {
p.dropTime = time.Now()
},
OnPlayerReholdFunc: nil,
OnPlayerEnterSceneBeforeFunc: nil,
OnPlayerEnterSceneAfterFunc: nil,

View File

@ -21,6 +21,7 @@ import (
serverproto "mongo.games.com/game/protocol/server"
webapiproto "mongo.games.com/game/protocol/webapi"
"mongo.games.com/game/srvdata"
"mongo.games.com/game/worldsrv/internal"
)
type PlayerGameCtx struct {
@ -193,6 +194,9 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
}
}
internal.FirePlayerEnterSceneBefore(p, this)
defer internal.FirePlayerEnterSceneAfter(p, this)
// 非百人,设置座位
if !this.IsHundredScene() {
if pos != -1 {
@ -515,6 +519,9 @@ func (this *Scene) lastScene(p *Player) {
}
func (this *Scene) DelPlayer(p *Player) bool {
internal.FirePlayerLeaveSceneBefore(p, this)
defer internal.FirePlayerLeaveSceneAfter(p, this)
if p.scene != this {
roomId := 0
if p.scene != nil {