add:对局中玩家人数上报
This commit is contained in:
parent
1f24dd29b6
commit
0c65af22ea
|
@ -250,6 +250,7 @@ func RegisterClockFunc(fs *ClockFunc) {
|
|||
if fs == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if fs.OnSecTimerFunc != nil {
|
||||
fs.event = fs.event | 1<<ClockEventSecond
|
||||
}
|
||||
|
@ -272,5 +273,9 @@ func RegisterClockFunc(fs *ClockFunc) {
|
|||
fs.event = fs.event | 1<<ClockEventShutdown
|
||||
}
|
||||
|
||||
if fs.event == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
ClockMgrSingleton.RegisterSinker(fs)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,13 @@ func GenerateOnline(online map[string]map[string]int) *mq.RabbitMQData {
|
|||
return NewRabbitMQData(mq.BackOnline, params)
|
||||
}
|
||||
|
||||
func GenerateOnlineGame(online map[string]map[string]map[string]map[int]map[int]int) *mq.RabbitMQData {
|
||||
params := make(map[string]interface{})
|
||||
params["Online"] = online
|
||||
params["Time"] = time.Now().Unix()
|
||||
return NewRabbitMQData(mq.BackOnlineGame, params)
|
||||
}
|
||||
|
||||
// GenerateLogin 玩家登陆事件
|
||||
func GenerateLogin(o *PlayerLoginEvent) *mq.RabbitMQData {
|
||||
return NewRabbitMQData(mq.BackLogin, o)
|
||||
|
|
|
@ -18,6 +18,7 @@ const (
|
|||
BackSystemPermitTask = "back_permittask"
|
||||
BackSystemJyb = "back_jyblog"
|
||||
BackActivityLog = "back_activitylog"
|
||||
BackOnlineGame = "back_onlinegame"
|
||||
)
|
||||
|
||||
// mgrsrv
|
||||
|
|
|
@ -324,8 +324,6 @@ func (this *Player) OnLogined() {
|
|||
|
||||
this.DealShopLog()
|
||||
|
||||
PlayerOnlineSington.Check = true
|
||||
|
||||
this.LoadMessage(tLastLogout.Unix(), isFirstLogin, !inSameWeek)
|
||||
|
||||
//登录次数
|
||||
|
@ -401,7 +399,6 @@ func (this *Player) OnRehold() {
|
|||
if !this.IsRob {
|
||||
TournamentMgr.Quit(this.Platform, this.SnId) // 比赛没有开始,退赛
|
||||
this.SendJackPotInit()
|
||||
PlayerOnlineSington.Check = true
|
||||
|
||||
this.DealShopLog()
|
||||
|
||||
|
@ -1188,7 +1185,6 @@ func (this *Player) DropLine() {
|
|||
|
||||
this.SendPlayerCoin()
|
||||
this.OnlineLogDrop()
|
||||
PlayerOnlineSington.Check = true
|
||||
}
|
||||
|
||||
if this.scene != nil && this.scene.gameSess != nil {
|
||||
|
@ -1222,7 +1218,6 @@ func (this *Player) OnLogoutFinish() {
|
|||
|
||||
if !this.IsRobot() {
|
||||
FriendUnreadMgrSington.SaveFriendUnreadData(this.Platform, this.SnId)
|
||||
PlayerOnlineSington.Check = true
|
||||
|
||||
//登录日志
|
||||
logState := LoginStateMgrSington.GetLoginStateBySid(this.sid)
|
||||
|
|
|
@ -8,8 +8,40 @@ import (
|
|||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/mq"
|
||||
"mongo.games.com/game/worldsrv/internal"
|
||||
)
|
||||
|
||||
func init() {
|
||||
module.RegisteModule(PlayerOnlineSington, 5*time.Second, 0)
|
||||
|
||||
internal.RegisterPlayerListenerFunc(&internal.PlayerListenerFunc[*Player, *Scene]{
|
||||
OnPlayerLoginedFunc: func(p *Player) {
|
||||
if p == nil || p.IsRob {
|
||||
return
|
||||
}
|
||||
PlayerOnlineSington.Check = true
|
||||
},
|
||||
OnPlayerLogoutedFunc: func(p *Player) {
|
||||
if p == nil || p.IsRob {
|
||||
return
|
||||
}
|
||||
PlayerOnlineSington.Check = true
|
||||
},
|
||||
OnPlayerDropLineFunc: func(p *Player) {
|
||||
if p == nil || p.IsRob {
|
||||
return
|
||||
}
|
||||
PlayerOnlineSington.Check = true
|
||||
},
|
||||
OnPlayerReholdFunc: func(p *Player) {
|
||||
if p == nil || p.IsRob {
|
||||
return
|
||||
}
|
||||
PlayerOnlineSington.Check = true
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
var PlayerOnlineSington = &PlayerOnlineEvent{
|
||||
OnlineCh: make(map[string]map[string]int),
|
||||
}
|
||||
|
@ -66,7 +98,3 @@ here:
|
|||
func (p *PlayerOnlineEvent) Shutdown() {
|
||||
module.UnregisteModule(p)
|
||||
}
|
||||
|
||||
func init() {
|
||||
module.RegisteModule(PlayerOnlineSington, 5*time.Second, 0)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/mq"
|
||||
"mongo.games.com/game/worldsrv/internal"
|
||||
)
|
||||
|
||||
func init() {
|
||||
module.RegisteModule(PlayerOnlineGameSingleton, 10*time.Second, 0)
|
||||
|
||||
internal.RegisterPlayerListenerFunc(&internal.PlayerListenerFunc[*Player, *Scene]{
|
||||
OnPlayerEnterSceneAfterFunc: func(p *Player, s *Scene) {
|
||||
if p == nil || p.IsRob {
|
||||
return
|
||||
}
|
||||
PlayerOnlineGameSingleton.Check = true
|
||||
},
|
||||
OnPlayerLeaveSceneAfterFunc: func(p *Player, s *Scene) {
|
||||
if p == nil || p.IsRob {
|
||||
return
|
||||
}
|
||||
PlayerOnlineGameSingleton.Check = true
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
var PlayerOnlineGameSingleton = &PlayerOnlineGameEvent{
|
||||
Online: make(map[string]map[string]map[string]map[int]map[int]int),
|
||||
}
|
||||
|
||||
type PlayerOnlineGameEvent struct {
|
||||
Online map[string]map[string]map[string]map[int]map[int]int // 平台:推广渠道:游戏组:游戏id:场次id:在线人数
|
||||
Check bool
|
||||
}
|
||||
|
||||
func (p *PlayerOnlineGameEvent) ModuleName() string {
|
||||
return "PlayerOnlineGameEvent"
|
||||
}
|
||||
|
||||
func (p *PlayerOnlineGameEvent) Init() {
|
||||
}
|
||||
|
||||
func (p *PlayerOnlineGameEvent) Update() {
|
||||
if !p.Check {
|
||||
return
|
||||
}
|
||||
p.Check = false
|
||||
|
||||
onlineCh := make(map[string]map[string]map[string]map[int]map[int]int)
|
||||
|
||||
for _, v := range SceneMgrSingleton.scenes {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
plt := SceneMgrSingleton.GetPlatformBySceneId(v.sceneId)
|
||||
// 平台
|
||||
if _, ok := onlineCh[plt]; !ok {
|
||||
onlineCh[plt] = map[string]map[string]map[int]map[int]int{}
|
||||
}
|
||||
|
||||
for _, player := range v.players {
|
||||
if player == nil || player.IsRob || player.Platform == common.Platform_Rob && player.Channel == common.Channel_Rob {
|
||||
continue
|
||||
}
|
||||
|
||||
// 渠道
|
||||
if _, ok := onlineCh[plt][player.ChannelId]; !ok {
|
||||
onlineCh[plt][player.ChannelId] = map[string]map[int]map[int]int{}
|
||||
}
|
||||
// 游戏组
|
||||
if _, ok := onlineCh[plt][player.ChannelId][v.dbGameFree.GetGameDif()]; !ok {
|
||||
onlineCh[plt][player.ChannelId][v.dbGameFree.GetGameDif()] = map[int]map[int]int{}
|
||||
}
|
||||
// 游戏id
|
||||
if _, ok := onlineCh[plt][player.ChannelId][v.dbGameFree.GetGameDif()][int(v.dbGameFree.GetGameId())]; !ok {
|
||||
onlineCh[plt][player.ChannelId][v.dbGameFree.GetGameDif()][int(v.dbGameFree.GetGameId())] = map[int]int{}
|
||||
}
|
||||
onlineCh[plt][player.ChannelId][v.dbGameFree.GetGameDif()][int(v.dbGameFree.GetGameId())][int(v.dbGameFree.GetId())] += 1
|
||||
}
|
||||
}
|
||||
|
||||
// 判断差异
|
||||
if !slices.Equal(maps.Keys(p.Online), maps.Keys(onlineCh)) {
|
||||
goto here
|
||||
}
|
||||
for k, v := range p.Online {
|
||||
if !slices.Equal(maps.Keys(v), maps.Keys(onlineCh[k])) {
|
||||
goto here
|
||||
}
|
||||
for k1, v1 := range v {
|
||||
if !slices.Equal(maps.Keys(v1), maps.Keys(onlineCh[k][k1])) {
|
||||
goto here
|
||||
}
|
||||
for k2, v2 := range v1 {
|
||||
if !slices.Equal(maps.Keys(v2), maps.Keys(onlineCh[k][k1][k2])) {
|
||||
goto here
|
||||
}
|
||||
for k3, v3 := range v2 {
|
||||
if !slices.Equal(maps.Keys(v3), maps.Keys(onlineCh[k][k1][k2][k3])) {
|
||||
goto here
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
here:
|
||||
p.Online = onlineCh
|
||||
mq.Write(model.GenerateOnlineGame(p.Online))
|
||||
logger.Logger.Trace("PlayerOnlineGameEvent", p.Online)
|
||||
}
|
||||
|
||||
func (p *PlayerOnlineGameEvent) Shutdown() {
|
||||
module.UnregisteModule(p)
|
||||
}
|
|
@ -162,6 +162,10 @@ func NewScene(args *CreateSceneParam) *Scene {
|
|||
return s
|
||||
}
|
||||
|
||||
func (this *Scene) GetPlatform() *Platform {
|
||||
return this.platform
|
||||
}
|
||||
|
||||
func (this *Scene) RobotIsLimit() bool {
|
||||
if this.robotLimit != 0 {
|
||||
if this.robotNum >= this.robotLimit {
|
||||
|
|
Loading…
Reference in New Issue