1
This commit is contained in:
parent
7edbb6eafb
commit
53ebf98467
@ -1,12 +1,31 @@
|
|||||||
package session
|
package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"q5"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type session struct {
|
||||||
|
accountId string
|
||||||
|
lastUpdateTick int64
|
||||||
|
}
|
||||||
|
|
||||||
type sessionMgr struct {
|
type sessionMgr struct {
|
||||||
idHash sync.Map
|
idHash sync.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *sessionMgr) UpdateSession(accountId string, sessionId string) {
|
func (this *sessionMgr) UpdateSession(accountId string, sessionId string) {
|
||||||
|
session := this.getSession(accountId)
|
||||||
|
if session != nil {
|
||||||
|
session.lastUpdateTick = q5.GetTickCount()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *sessionMgr) getSession(accountId string) *session {
|
||||||
|
if p, ok := this.idHash.Load(accountId); ok {
|
||||||
|
return p.(*session)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user