diff --git a/server/statserver/router/ca/enter.go b/server/statserver/router/ca/enter.go deleted file mode 100644 index 16c10a3f..00000000 --- a/server/statserver/router/ca/enter.go +++ /dev/null @@ -1,5 +0,0 @@ -package ca - -type RouterGroup struct { - StatRouter -} diff --git a/server/statserver/router/ca/stat.go b/server/statserver/router/ca/stat.go deleted file mode 100644 index 890c1a08..00000000 --- a/server/statserver/router/ca/stat.go +++ /dev/null @@ -1,13 +0,0 @@ -package ca - -import ( - "f5" - "main/api/ca" -) - -type StatRouter struct{} - -func (this *StatRouter) InitStatRouter() { - f5.GetApp().RegisterCaHandle("Stat", "updateSession", ca.ApiGroupApp.UpdateSession) - f5.GetApp().RegisterCaHandle("Ops", "getOnlineNum", ca.ApiGroupApp.GetOnlineNum) -} diff --git a/server/statserver/router/export.go b/server/statserver/router/export.go deleted file mode 100644 index fcab4622..00000000 --- a/server/statserver/router/export.go +++ /dev/null @@ -1,12 +0,0 @@ -package router - -import ( - "main/constant" - "main/global" -) - -var _routerMgr = new(routerMgr) - -func init() { - global.RegModule(constant.ROUTER_MGR_MODULE_IDX, _routerMgr) -} diff --git a/server/statserver/router/routermgr.go b/server/statserver/router/routermgr.go deleted file mode 100644 index ea6aa712..00000000 --- a/server/statserver/router/routermgr.go +++ /dev/null @@ -1,23 +0,0 @@ -package router - -import ( - "f5" - "main/router/ca" -) - -type routerMgr struct { - ca ca.RouterGroup -} - -func (this *routerMgr) Init() { - /* - f5.GetApp().GetGinEngine().Use(middleware.Cors()) - */ - this.ca.InitGameLogRouter() - f5.GetSysLog().Info("routerMgr.init") - -} - -func (this *routerMgr) UnInit() { - -} diff --git a/server/statserver/session/export.go b/server/statserver/session/export.go deleted file mode 100644 index 61b9d757..00000000 --- a/server/statserver/session/export.go +++ /dev/null @@ -1,12 +0,0 @@ -package session - -import ( - "main/constant" - "main/global" -) - -var _sessionMgr = new (sessionMgr) - -func init() { - global.RegModule(constant.SESSION_MGR_MODULE_IDX, _sessionMgr) -} diff --git a/server/statserver/session/sessionmgr.go b/server/statserver/session/sessionmgr.go deleted file mode 100644 index 7271279e..00000000 --- a/server/statserver/session/sessionmgr.go +++ /dev/null @@ -1,121 +0,0 @@ -package session - -import ( - "q5" - "f5" - "time" - "sync" - "main/mt" -) - -type userSession struct { - accountId string - sessionId string - lastUpdateTime int64 - timerWp *q5.XTimerWp - onlineNum int64 -} - -type sessionMgr struct { - idHash sync.Map - lock sync.Mutex - timer *q5.XTimer -} - -func (this *sessionMgr) Init() { - this.timer = new(q5.XTimer) - this.timer.Init( - func (context interface{}) int64 { - return f5.GetApp().GetRealSeconds() - }, - this, - 60, - 10000) - go this.updateTimer() -} - -func (this *sessionMgr) UnInit() { -} - -func (this *sessionMgr) UpdateSession(accountId string, sessionId string) { - session := this.getSession(accountId) - if session != nil { - session.lastUpdateTime = f5.GetApp().GetRealSeconds() - return - } - defer this.lock.Unlock() - this.lock.Lock() - session = this.getSession(accountId) - if session != nil { - session.lastUpdateTime = f5.GetApp().GetRealSeconds() - } else { - session = new(userSession) - session.accountId = accountId - session.sessionId = sessionId - session.lastUpdateTime = f5.GetApp().GetRealSeconds() - this.idHash.Store(accountId, session) - this.userOnline(session) - 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 >= mt.Table.Config.GetSessionExpireTime() { - this.idHash.Delete(session.accountId) - this.timer.DeleteRunningTimer() - this.userOffline(session) - } else { - this.timer.ModifyTimer(session.timerWp, 10) - } - } - }) - } -} - -func (this *sessionMgr) getSession(accountId string) *userSession { - if p, ok := this.idHash.Load(accountId); ok { - return p.(*userSession) - } else { - return nil - } -} - -func (this *sessionMgr) updateTimer() { - for true { - this.lock.Lock() - this.timer.Update() - this.lock.Unlock() - time.Sleep(1 * time.Second); - } -} - - -func (this *sessionMgr) userOnline(session *userSession) { - prop := map[string]string{} - prop["gameid"] = q5.ToString(constant.GAME_ID) - f5.GetTgLog().AddTrackLog( - constant.GAME_ID, - session.accountId, - "", //distance_id - "", //ip - "user_online", - prop) - atomic.AddInt64(&this.onlineNum, 1) -} - -func (this *sessionMgr) userOffline(session *userSession) { - prop := map[string]string{} - prop["gameid"] = q5.ToString(constant.GAME_ID) - f5.GetTgLog().AddTrackLog( - constant.GAME_ID, - session.accountId, - "", //distance_id - "", //ip - "user_offline", - prop) - atomic.AddInt64(&this.onlineNum, -1) -} - -func (this *sessionMgr) GetOnlineNum() int64 { - return this.onlineNum -}