1
This commit is contained in:
parent
9329fae43e
commit
5d1b42b237
@ -6,3 +6,7 @@ import (
|
||||
type App interface {
|
||||
Run(func(), func())
|
||||
}
|
||||
|
||||
type SessionMgr interface {
|
||||
UpdateSession(accountId string, sessionId string)
|
||||
}
|
||||
|
@ -3,5 +3,6 @@ package constant
|
||||
const (
|
||||
APP_MODULE_IDX = iota
|
||||
CONTROLLER_MGR_MODULE_IDX
|
||||
SESSION_MGR_MODULE_IDX
|
||||
MAX_MODULE_IDX
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"main/session"
|
||||
. "main/global"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -12,7 +12,7 @@ type Stat struct {
|
||||
func (this *Stat) caUpdateSession(c *gin.Context) {
|
||||
accountId := c.DefaultQuery("account_id", "")
|
||||
sessionId := c.DefaultQuery("session_id", "")
|
||||
session.SessionMgr.UpdateSession(accountId, sessionId);
|
||||
GetSessionMgr().UpdateSession(accountId, sessionId);
|
||||
rspObj := struct {
|
||||
ErrCode int32 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
|
@ -9,14 +9,19 @@ import (
|
||||
|
||||
var modules [constant.MAX_MODULE_IDX]q5.Module
|
||||
var initOrders = []int32{
|
||||
constant.SESSION_MGR_MODULE_IDX,
|
||||
}
|
||||
|
||||
var app common.App
|
||||
var sessionMgr common.SessionMgr
|
||||
|
||||
func GetApp() common.App {
|
||||
return app
|
||||
}
|
||||
|
||||
func GetSessionMgr() common.SessionMgr {
|
||||
return sessionMgr
|
||||
}
|
||||
|
||||
func RegModule(idx int32, m q5.Module) {
|
||||
fmt.Printf("RegModule module %d\n", idx)
|
||||
@ -26,6 +31,10 @@ func RegModule(idx int32, m q5.Module) {
|
||||
{
|
||||
app = m.(common.App)
|
||||
}
|
||||
case constant.SESSION_MGR_MODULE_IDX:
|
||||
{
|
||||
sessionMgr = m.(common.SessionMgr)
|
||||
}
|
||||
default:
|
||||
{
|
||||
panic("unknow module")
|
||||
|
@ -1,3 +1,12 @@
|
||||
package session
|
||||
|
||||
var SessionMgr = new (sessionMgr)
|
||||
import (
|
||||
"main/constant"
|
||||
"main/global"
|
||||
)
|
||||
|
||||
var _sessionMgr = new (sessionMgr)
|
||||
|
||||
func init() {
|
||||
global.RegModule(constant.SESSION_MGR_MODULE_IDX, _sessionMgr)
|
||||
}
|
||||
|
@ -16,6 +16,12 @@ type sessionMgr struct {
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
func (this *sessionMgr) Init() {
|
||||
}
|
||||
|
||||
func (this *sessionMgr) UnInit() {
|
||||
}
|
||||
|
||||
func (this *sessionMgr) UpdateSession(accountId string, sessionId string) {
|
||||
session := this.getSession(accountId)
|
||||
if session != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user