This commit is contained in:
aozhiwei 2020-11-30 16:30:19 +08:00
parent 6320916b24
commit a2ed440577
4 changed files with 48 additions and 0 deletions

View File

@ -17,11 +17,13 @@ func (this *App_) Init() {
G.MetaMgr = new(MetaMgr).Init()
G.GameLog = new(GameLog).Init()
G.HttpServer = new(f5.HttpServer).Init("httpserver", 1000 * 60)
G.GameMgr = new(GameMgr).Init()
G.HttpServer.Start(G.MetaMgr.GetCurrServer().GetListenPort());
}
func (this *App_) UnInit() {
G.GameMgr.UnInit()
G.HttpServer.UnInit()
G.GameLog.UnInit()
G.MetaMgr.UnInit()

View File

@ -8,6 +8,7 @@ type GlobalVar struct {
MetaMgr *MetaMgr
HttpServer *f5.HttpServer
GameLog *GameLog
GameMgr *GameMgr
}
var G *GlobalVar = &GlobalVar{}

View File

@ -0,0 +1,15 @@
package main
type Game2005 struct {
}
func (this *Game2005) Init() {
}
func (this *Game2005) UnInit() {
}
func (this *Game2005) GetGameId() int32 {
return 2005
}

30
server/mailman/gamemgr.go Normal file
View File

@ -0,0 +1,30 @@
package main
type Game interface {
Init()
UnInit()
GetGameId() int32
}
type GameMgr struct {
gameHash map[int32]Game
}
func (this *GameMgr) Init() *GameMgr {
this.gameHash = make(map[int32]Game)
this.gameHash[2005] = new(Game2005)
for gameId, val := range(this.gameHash) {
if (gameId != val.GetGameId()) {
panic("GameMgr gameId error!")
}
val.Init()
}
return this
}
func (this *GameMgr) UnInit() {
for _, val := range(this.gameHash) {
val.UnInit()
}
}