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 accountId string
sessionId string sessionId string
lastUpdateTime int64 lastUpdateTime int64
timerWp *q5.XTimerWp
} }
type sessionMgr struct { type sessionMgr struct {
@ -40,20 +41,23 @@ func (this *sessionMgr) UpdateSession(accountId string, sessionId string) {
session.lastUpdateTime = f5.GetApp().GetRealSeconds() session.lastUpdateTime = f5.GetApp().GetRealSeconds()
return return
} }
defer this.lock.Unlock()
this.lock.Lock() this.lock.Lock()
session = this.getSession(accountId) session = this.getSession(accountId)
if session != nil { if session != nil {
session.lastUpdateTime = f5.GetApp().GetRealSeconds() session.lastUpdateTime = f5.GetApp().GetRealSeconds()
this.lock.Unlock() } else {
return
}
session = new(userSession) session = new(userSession)
session.accountId = accountId session.accountId = accountId
session.sessionId = sessionId session.sessionId = sessionId
session.lastUpdateTime = f5.GetApp().GetRealSeconds() session.lastUpdateTime = f5.GetApp().GetRealSeconds()
this.idHash.Store(accountId, session) 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 { func (this *sessionMgr) getSession(accountId string) *userSession {