This commit is contained in:
aozhiwei 2024-05-25 11:58:31 +08:00
parent 4196be22f3
commit 1b8d3472a0

View File

@ -11,6 +11,7 @@ type userSession struct {
accountId string
sessionId string
lastUpdateTime int64
timerWp *q5.XTimerWp
}
type sessionMgr struct {
@ -40,20 +41,23 @@ func (this *sessionMgr) UpdateSession(accountId string, sessionId string) {
session.lastUpdateTime = f5.GetApp().GetRealSeconds()
return
}
defer this.lock.Unlock()
this.lock.Lock()
session = this.getSession(accountId)
if session != nil {
session.lastUpdateTime = f5.GetApp().GetRealSeconds()
this.lock.Unlock()
return
}
} else {
session = new(userSession)
session.accountId = accountId
session.sessionId = sessionId
session.lastUpdateTime = f5.GetApp().GetRealSeconds()
this.idHash.Store(accountId, session)
this.lock.Unlock()
session.timerWp = this.timer.SetIntervalWp(
1,
func (e int32, args *q5.Args) {
})
}
}
func (this *sessionMgr) getSession(accountId string) *userSession {