1
This commit is contained in:
parent
6320916b24
commit
a2ed440577
@ -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()
|
||||
|
@ -8,6 +8,7 @@ type GlobalVar struct {
|
||||
MetaMgr *MetaMgr
|
||||
HttpServer *f5.HttpServer
|
||||
GameLog *GameLog
|
||||
GameMgr *GameMgr
|
||||
}
|
||||
|
||||
var G *GlobalVar = &GlobalVar{}
|
||||
|
15
server/mailman/game2005.go
Normal file
15
server/mailman/game2005.go
Normal 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
30
server/mailman/gamemgr.go
Normal 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()
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user