This commit is contained in:
aozhiwei 2024-05-26 13:14:33 +08:00
parent 90ef5607fb
commit cfdf663d3d
10 changed files with 79 additions and 10 deletions

View File

@ -0,0 +1,7 @@
package ca
type ApiGroup struct {
StatApi
}
var ApiGroupApp = new(ApiGroup)

View File

@ -1,15 +1,15 @@
package controller
package ca
import (
. "main/global"
"github.com/gin-gonic/gin"
)
type Stat struct {
type StatApi struct {
}
func (this *Stat) caUpdateSession(c *gin.Context) {
func (this *StatApi) UpdateSession(c *gin.Context) {
accountId := c.DefaultQuery("account_id", "")
sessionId := c.DefaultQuery("session_id", "")
GetSessionMgr().UpdateSession(accountId, sessionId);
@ -23,7 +23,7 @@ func (this *Stat) caUpdateSession(c *gin.Context) {
c.JSON(200, rspObj)
}
func (this *Stat) caGetonlineNum(c *gin.Context) {
func (this *StatApi) GetOnlineNum(c *gin.Context) {
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`

View File

@ -1,5 +0,0 @@
package controller
import (
)

View File

@ -11,3 +11,7 @@ type SessionMgr interface {
UpdateSession(accountId string, sessionId string)
GetOnlineNum() int64
}
type RouterMgr interface {
}

View File

@ -2,7 +2,7 @@ package constant
const (
APP_MODULE_IDX = iota
CONTROLLER_MGR_MODULE_IDX
ROUTER_MGR_MODULE_IDX
SESSION_MGR_MODULE_IDX
MAX_MODULE_IDX
)

View File

@ -9,16 +9,22 @@ import (
var modules [constant.MAX_MODULE_IDX]q5.Module
var initOrders = []int32{
constant.ROUTER_MGR_MODULE_IDX,
constant.SESSION_MGR_MODULE_IDX,
}
var app common.App
var routerMgr common.RouterMgr
var sessionMgr common.SessionMgr
func GetApp() common.App {
return app
}
func GetRouterMgr() common.RouterMgr {
return routerMgr
}
func GetSessionMgr() common.SessionMgr {
return sessionMgr
}
@ -31,6 +37,10 @@ func RegModule(idx int32, m q5.Module) {
{
app = m.(common.App)
}
case constant.ROUTER_MGR_MODULE_IDX:
{
routerMgr = m.(common.RouterMgr)
}
case constant.SESSION_MGR_MODULE_IDX:
{
sessionMgr = m.(common.SessionMgr)

View File

@ -0,0 +1,5 @@
package ca
type RouterGroup struct {
StatRouter
}

View File

@ -0,0 +1,13 @@
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)
}

View File

@ -0,0 +1,12 @@
package router
import (
"main/constant"
"main/global"
)
var _routerMgr = new(routerMgr)
func init() {
global.RegModule(constant.ROUTER_MGR_MODULE_IDX, _routerMgr)
}

View File

@ -0,0 +1,23 @@
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() {
}