Merge branch 'release' into develop
This commit is contained in:
commit
5ca1048b18
|
@ -99,6 +99,7 @@ func SCPlayerFlag(s *netlib.Session, packetid int, data interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新房间里玩家的状态
|
||||||
if scene, ok := GetScene(s).(IScene); ok && scene != nil {
|
if scene, ok := GetScene(s).(IScene); ok && scene != nil {
|
||||||
p := scene.GetPlayerBySnid(msg.GetPlayerId())
|
p := scene.GetPlayerBySnid(msg.GetPlayerId())
|
||||||
if p != nil {
|
if p != nil {
|
|
@ -52,6 +52,7 @@ func SCDestroyRoom(s *netlib.Session, packid int, pack interface{}) error {
|
||||||
|
|
||||||
if msg.GetOpRetCode() == gamehallproto.OpResultCode_Game_OPRC_Sucess_Game {
|
if msg.GetOpRetCode() == gamehallproto.OpResultCode_Game_OPRC_Sucess_Game {
|
||||||
cleanRoomState(s)
|
cleanRoomState(s)
|
||||||
|
SceneMgrSingleton.DelScene(msg.GetRoomId())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,12 @@ import (
|
||||||
func init() {
|
func init() {
|
||||||
common.RegisterClockFunc(&common.ClockFunc{
|
common.RegisterClockFunc(&common.ClockFunc{
|
||||||
OnHourTimerFunc: func() {
|
OnHourTimerFunc: func() {
|
||||||
ClientMgrSingleton.HourChange()
|
ClientMgrSingleton.AccountReplace()
|
||||||
|
|
||||||
logger.Logger.Infof("client state: %+v", ClientMgrSingleton.GetState())
|
logger.Logger.Info(ClientMgrSingleton.GetState())
|
||||||
},
|
},
|
||||||
OnDayTimerFunc: func() {
|
OnDayTimerFunc: func() {
|
||||||
ClientMgrSingleton.DayChange()
|
ClientMgrSingleton.AccountDeletePolicy()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -110,13 +110,17 @@ func (this *ClientMgr) UnRegisterSession(acc string) {
|
||||||
delete(this.sessionPool, acc)
|
delete(this.sessionPool, acc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ClientMgr) HourChange() {
|
// AccountReplace 账号替换
|
||||||
|
func (this *ClientMgr) AccountReplace() {
|
||||||
fileModify := false
|
fileModify := false
|
||||||
eventArr := this.CycleTimeEvent[time.Now().Hour()]
|
eventArr := this.CycleTimeEvent[time.Now().Hour()]
|
||||||
for _, event := range eventArr {
|
for _, event := range eventArr {
|
||||||
accChan[event.newAcc] = true //使用新的账号
|
accChan[event.newAcc] = true //使用新的账号
|
||||||
cfg := NewSessionConfig()
|
|
||||||
netlib.Connect(cfg) //创建新的连接
|
//创建新的连接
|
||||||
|
NewSession()
|
||||||
|
|
||||||
|
// 关闭旧的连接
|
||||||
if session, ok := this.sessionPool[event.oldAcc]; ok && session != nil {
|
if session, ok := this.sessionPool[event.oldAcc]; ok && session != nil {
|
||||||
//删除旧有账号数据
|
//删除旧有账号数据
|
||||||
pack := &serverproto.RWAccountInvalid{
|
pack := &serverproto.RWAccountInvalid{
|
||||||
|
@ -128,6 +132,7 @@ func (this *ClientMgr) HourChange() {
|
||||||
//关闭连接
|
//关闭连接
|
||||||
session.Close()
|
session.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新本地账号数据信息
|
//更新本地账号数据信息
|
||||||
for key, value := range accPool {
|
for key, value := range accPool {
|
||||||
if value.Acc == event.oldAcc {
|
if value.Acc == event.oldAcc {
|
||||||
|
@ -156,7 +161,8 @@ func (this *ClientMgr) HourChange() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ClientMgr) DayChange() {
|
// AccountDeletePolicy 账号删除策略
|
||||||
|
func (this *ClientMgr) AccountDeletePolicy() {
|
||||||
invalidCount := 0 //过期账号数量
|
invalidCount := 0 //过期账号数量
|
||||||
updateLimit := len(accPool) * model.GameParamData.InvalidRobotAccRate / 100 //可更新的账号数量
|
updateLimit := len(accPool) * model.GameParamData.InvalidRobotAccRate / 100 //可更新的账号数量
|
||||||
invalidAccs := []InvalidAcc{}
|
invalidAccs := []InvalidAcc{}
|
||||||
|
@ -201,6 +207,10 @@ type ClientState struct {
|
||||||
Event map[int]int
|
Event map[int]int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ClientState) String() string {
|
||||||
|
return fmt.Sprintf("ClientMgrState 连接总数:%v, 每小时账号替换数量:%v", c.SessionNum, c.Event)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *ClientMgr) GetState() *ClientState {
|
func (this *ClientMgr) GetState() *ClientState {
|
||||||
ret := &ClientState{
|
ret := &ClientState{
|
||||||
SessionNum: len(this.sessionPool),
|
SessionNum: len(this.sessionPool),
|
||||||
|
|
|
@ -18,12 +18,19 @@ var (
|
||||||
WaitConnectSessions []*netlib.SessionConfig
|
WaitConnectSessions []*netlib.SessionConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewSessionConfig() *netlib.SessionConfig {
|
// NewSession 新建session
|
||||||
BenchMarkModule.idx++
|
// id 连接id, 默认自动分配
|
||||||
|
func NewSession(id ...int) {
|
||||||
cfg := Config.Connects
|
cfg := Config.Connects
|
||||||
|
if len(id) > 0 && id[0] > 0 {
|
||||||
|
cfg.Id = id[0]
|
||||||
|
} else {
|
||||||
|
BenchMarkModule.idx++
|
||||||
cfg.Id = BenchMarkModule.idx
|
cfg.Id = BenchMarkModule.idx
|
||||||
|
}
|
||||||
cfg.Init()
|
cfg.Init()
|
||||||
return &cfg
|
logger.Logger.Info("waite connect session id=", cfg.Id)
|
||||||
|
WaitConnectSessions = append(WaitConnectSessions, &cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
type BenchMark struct {
|
type BenchMark struct {
|
||||||
|
@ -37,9 +44,7 @@ func (m *BenchMark) ModuleName() string {
|
||||||
func (m *BenchMark) Init() {
|
func (m *BenchMark) Init() {
|
||||||
m.idx = RobotSessionStartId
|
m.idx = RobotSessionStartId
|
||||||
for i := 0; i < Config.Count; i++ {
|
for i := 0; i < Config.Count; i++ {
|
||||||
cfg := NewSessionConfig()
|
NewSession()
|
||||||
logger.Logger.Info("waite connect session id=", cfg.Id)
|
|
||||||
WaitConnectSessions = append(WaitConnectSessions, cfg)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,7 @@ func (g *GateSessionHandler) OnSessionClosed(s *netlib.Session) {
|
||||||
StopSessionPingTimer(s)
|
StopSessionPingTimer(s)
|
||||||
if reconnect {
|
if reconnect {
|
||||||
logger.Logger.Infof("账号重连 sessionID:%v account:%v", s.Id, accIdParam)
|
logger.Logger.Infof("账号重连 sessionID:%v account:%v", s.Id, accIdParam)
|
||||||
cfg := Config.Connects
|
NewSession(s.GetSessionConfig().Id)
|
||||||
cfg.Id = s.GetSessionConfig().Id
|
|
||||||
cfg.Init()
|
|
||||||
WaitConnectSessions = append(WaitConnectSessions, &cfg)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@ type AccountData struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// 待使用的账号,将要建立连接
|
// 待登录的账号,将要建立连接
|
||||||
accChan = make(map[string]bool)
|
accChan = make(map[string]bool)
|
||||||
// 账号池,当前正在使用的机器人
|
// 账号池,当前正在使用的机器人账号
|
||||||
accPool []*AccountData
|
accPool []*AccountData
|
||||||
)
|
)
|
||||||
var accountFileName = "robotaccount.json"
|
var accountFileName = "robotaccount.json"
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"mongo.games.com/game/common"
|
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
|
|
||||||
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
hall_proto "mongo.games.com/game/protocol/gamehall"
|
hall_proto "mongo.games.com/game/protocol/gamehall"
|
||||||
player_proto "mongo.games.com/game/protocol/player"
|
player_proto "mongo.games.com/game/protocol/player"
|
||||||
|
@ -20,6 +21,9 @@ func init() {
|
||||||
OnMiniTimerFunc: func() {
|
OnMiniTimerFunc: func() {
|
||||||
PlayerMgrSingleton.OnMiniTimer()
|
PlayerMgrSingleton.OnMiniTimer()
|
||||||
},
|
},
|
||||||
|
OnHourTimerFunc: func() {
|
||||||
|
logger.Logger.Info(PlayerMgrSingleton.GetState())
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,3 +177,22 @@ func (pm *PlayerMgr) OnSecondTimer() {
|
||||||
func (pm *PlayerMgr) OnMiniTimer() {
|
func (pm *PlayerMgr) OnMiniTimer() {
|
||||||
pm.ProcessCheckRobotNum()
|
pm.ProcessCheckRobotNum()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PlayerMgrState struct {
|
||||||
|
PlayerNum int
|
||||||
|
NormalSessionNum int
|
||||||
|
MatchSessionNum int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PlayerMgrState) String() string {
|
||||||
|
return fmt.Sprintf("PlayerMgrState 玩家总数:%v, 普通场连接数:%v, 比赛场连接数:%v", p.PlayerNum, p.NormalSessionNum, p.MatchSessionNum)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pm *PlayerMgr) GetState() *PlayerMgrState {
|
||||||
|
ret := &PlayerMgrState{
|
||||||
|
PlayerNum: len(pm.playersMapSnId),
|
||||||
|
NormalSessionNum: len(pm.playersSession),
|
||||||
|
MatchSessionNum: len(pm.playersMatchSession),
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
@ -16,11 +17,7 @@ func init() {
|
||||||
|
|
||||||
common.RegisterClockFunc(&common.ClockFunc{
|
common.RegisterClockFunc(&common.ClockFunc{
|
||||||
OnHourTimerFunc: func() {
|
OnHourTimerFunc: func() {
|
||||||
sceneState := map[int32]int{}
|
logger.Logger.Info(SceneMgrSingleton.GetState())
|
||||||
for _, v := range SceneMgrSingleton.Scenes {
|
|
||||||
sceneState[v.GetGameId()]++
|
|
||||||
}
|
|
||||||
logger.Logger.Infof("sceneState: %v", sceneState)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -71,6 +68,22 @@ func (sm *SceneMgr) IsFreeMode(sceneId int32) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SceneMgrState struct {
|
||||||
|
Num map[int32]int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SceneMgrState) String() string {
|
||||||
|
return fmt.Sprintf("SceneMgrState 每个游戏的房间数量 [游戏id:房间数量]: %v", s.Num)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sm *SceneMgr) GetState() *SceneMgrState {
|
||||||
|
m := make(map[int32]int)
|
||||||
|
for _, v := range sm.Scenes {
|
||||||
|
m[v.GetGameId()]++
|
||||||
|
}
|
||||||
|
return &SceneMgrState{Num: m}
|
||||||
|
}
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
// / Module Implement [beg]
|
// / Module Implement [beg]
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -38,6 +38,7 @@ type SceneMgr struct {
|
||||||
matchAutoId int // 比赛场房间号
|
matchAutoId int // 比赛场房间号
|
||||||
coinSceneAutoId int // 金币场房间号
|
coinSceneAutoId int // 金币场房间号
|
||||||
hundredSceneAutoId int // 百人场房间号
|
hundredSceneAutoId int // 百人场房间号
|
||||||
|
|
||||||
password map[string]struct{} // 密码
|
password map[string]struct{} // 密码
|
||||||
pushList map[int]struct{} // 已经推荐过的房间列表
|
pushList map[int]struct{} // 已经推荐过的房间列表
|
||||||
lastPushSceneId int // 最后推荐的房间id
|
lastPushSceneId int // 最后推荐的房间id
|
||||||
|
|
Loading…
Reference in New Issue