From 5fc3b988ddc6e83a173cdaf91d8dc3851e366340 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 25 May 2024 12:16:28 +0800 Subject: [PATCH] 1 --- server/statserver/mt/Config.go | 4 ++++ server/statserver/mtb/mtb.auto_gen.go | 10 ++++++++++ server/statserver/proto/mt.proto | 1 + server/statserver/session/sessionmgr.go | 10 ++++++++-- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/server/statserver/mt/Config.go b/server/statserver/mt/Config.go index 7438532d..39f961a2 100644 --- a/server/statserver/mt/Config.go +++ b/server/statserver/mt/Config.go @@ -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() +} diff --git a/server/statserver/mtb/mtb.auto_gen.go b/server/statserver/mtb/mtb.auto_gen.go index 0c3fbc2c..a69943f1 100644 --- a/server/statserver/mtb/mtb.auto_gen.go +++ b/server/statserver/mtb/mtb.auto_gen.go @@ -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) } diff --git a/server/statserver/proto/mt.proto b/server/statserver/proto/mt.proto index 9b764f9d..0038d275 100644 --- a/server/statserver/proto/mt.proto +++ b/server/statserver/proto/mt.proto @@ -21,4 +21,5 @@ message MailDb message Config { optional string gameapi_url = 1; + optional int32 session_expire_time = 2; } diff --git a/server/statserver/session/sessionmgr.go b/server/statserver/session/sessionmgr.go index 712a37d0..a846ccb9 100644 --- a/server/statserver/session/sessionmgr.go +++ b/server/statserver/session/sessionmgr.go @@ -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 { + } + } }) } }