This commit is contained in:
aozhiwei 2024-05-25 12:16:28 +08:00
parent 1b8d3472a0
commit 5fc3b988dd
4 changed files with 23 additions and 2 deletions

View File

@ -17,3 +17,7 @@ type ConfigTable struct {
func (this *ConfigTable) GetGameApiUrl() string {
return this.selfConf.GetGameapiUrl()
}
func (this *ConfigTable) GetSessionExpireTime() int32 {
return this.selfConf.GetSessionExpireTime()
}

View File

@ -26,6 +26,7 @@ type MailDb struct {
type Config struct {
gameapi_url string
session_expire_time int32
_flags1_ uint64
_flags2_ uint64
@ -103,6 +104,14 @@ func (this *Config) HasGameapiUrl() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *Config) GetSessionExpireTime() int32 {
return this.session_expire_time
}
func (this *Config) HasSessionExpireTime() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *MailCluster) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
@ -120,4 +129,5 @@ func (this *MailDb) LoadFromKv(kv map[string]interface{}) {
func (this *Config) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.session_expire_time, "session_expire_time", &this._flags1_, 2, kv)
}

View File

@ -21,4 +21,5 @@ message MailDb
message Config
{
optional string gameapi_url = 1;
optional int32 session_expire_time = 2;
}

View File

@ -5,6 +5,7 @@ import (
"f5"
"time"
"sync"
"main/mt"
)
type userSession struct {
@ -52,10 +53,15 @@ func (this *sessionMgr) UpdateSession(accountId string, sessionId string) {
session.sessionId = sessionId
session.lastUpdateTime = f5.GetApp().GetRealSeconds()
this.idHash.Store(accountId, session)
session.timerWp = this.timer.SetIntervalWp(
1,
session.timerWp = this.timer.SetTimeoutWp(
mt.Table.Config.GetSessionExpireTime(),
func (e int32, args *q5.Args) {
if e == q5.TIMER_EXEC_EVENT {
nowTime := f5.GetApp().GetRealSeconds()
if nowTime - session.lastUpdateTime > 0 {
}
}
})
}
}