优化GM服务器

This commit is contained in:
flswld committed 2023-10-23 23:00:41 +08:00
1 parent 00d32292ad
commit bea91fbf73
12 files changed
+152 -37

No files matched your search

+12
View File
@@ -122,3 +122,15 @@ func (c *Controller) serverDispatchCancel(ctx *gin.Context) {
}
ctx.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: nil})
}
type ServerOnlineStats struct {
TotalOnlinePlayerNum uint32 `json:"total_online_player_num"`
}
func (c *Controller) serverOnlineStats(ctx *gin.Context) {
num := 0
c.globalGsOnlineMapLock.RLock()
num = len(c.globalGsOnlineMap)
c.globalGsOnlineMapLock.RUnlock()
ctx.JSON(http.StatusOK, &CommonRsp{Code: 0, Msg: "", Data: &ServerOnlineStats{TotalOnlinePlayerNum: uint32(num)}})
}