This commit is contained in:
aozhiwei 2024-05-26 10:09:36 +08:00
parent a8a845cb33
commit 9d602144ba
3 changed files with 7 additions and 0 deletions

View File

@ -9,4 +9,5 @@ type App interface {
type SessionMgr interface {
UpdateSession(accountId string, sessionId string)
GetOnlineNum() int64
}

View File

@ -27,9 +27,11 @@ func (this *Stat) caGetonlineNum(c *gin.Context) {
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
Num int32 `json:"num"`
}{
ErrCode: 0,
ErrMsg: "",
Num: int32(GetSessionMgr().GetOnlineNum()),
}
c.JSON(200, rspObj)
}

View File

@ -115,3 +115,7 @@ func (this *sessionMgr) userOffline(session *userSession) {
prop)
atomic.AddInt64(&this.onlineNum, -1)
}
func (this *sessionMgr) GetOnlineNum() int64 {
return this.onlineNum
}