This commit is contained in:
aozhiwei 2024-05-25 12:22:16 +08:00
parent 5fc3b988dd
commit c8fc2ef264

View File

@ -53,13 +53,18 @@ func (this *sessionMgr) UpdateSession(accountId string, sessionId string) {
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.userOnline(session)
session.timerWp = this.timer.SetTimeoutWp( session.timerWp = this.timer.SetTimeoutWp(
mt.Table.Config.GetSessionExpireTime(), mt.Table.Config.GetSessionExpireTime(),
func (e int32, args *q5.Args) { func (e int32, args *q5.Args) {
if e == q5.TIMER_EXEC_EVENT { if e == q5.TIMER_EXEC_EVENT {
nowTime := f5.GetApp().GetRealSeconds() nowTime := f5.GetApp().GetRealSeconds()
if nowTime - session.lastUpdateTime > 0 { if nowTime - session.lastUpdateTime >= mt.Table.Config.GetSessionExpireTime() {
this.idHash.Delete(session.accountId)
this.timer.DeleteRunningTimer()
this.userOffline(session)
} else {
this.timer.ModifyTimer(session.timerWp, 10)
} }
} }
}) })
@ -82,3 +87,10 @@ func (this *sessionMgr) updateTimer() {
time.Sleep(1 * time.Second); time.Sleep(1 * time.Second);
} }
} }
func (this *sessionMgr) userOnline(session *userSession) {
}
func (this *sessionMgr) userOffline(session *userSession) {
}