1
This commit is contained in:
parent
c2b32f4d1b
commit
7086631f1a
@ -20,9 +20,10 @@ func (this *app) GetPkgName() string {
|
||||
return "imserver"
|
||||
}
|
||||
|
||||
func (this *app) SetCb(initCb func(), unInitCb func()) {
|
||||
func (this *app) Run(initCb func(), unInitCb func()) {
|
||||
this.initCb = initCb
|
||||
this.unInitCb = unInitCb
|
||||
f5.Run(this)
|
||||
}
|
||||
|
||||
func (this *app) Init() {
|
||||
|
@ -36,6 +36,6 @@ type HttpListener interface {
|
||||
}
|
||||
|
||||
type App interface {
|
||||
SetCb(func(), func())
|
||||
Run(func(), func())
|
||||
AddNetMsg(*f5.MsgHdr)
|
||||
}
|
||||
|
@ -21,5 +21,6 @@ const (
|
||||
WSPLISTENER_MODULE_IDX
|
||||
HANDLER_MGR_MODULE_IDX
|
||||
HTTP_LISTENER_MODULE_IDX
|
||||
PLAYER_MGR_MODULE_IDX
|
||||
MAX_MODULE_IDX
|
||||
)
|
||||
|
@ -7,6 +7,13 @@ import (
|
||||
)
|
||||
|
||||
var modules [constant.MAX_MODULE_IDX]q5.Module
|
||||
var initOrders = []int32 {
|
||||
constant.HTTP_LISTENER_MODULE_IDX,
|
||||
constant.PLAYER_MGR_MODULE_IDX,
|
||||
constant.ROOMMGR_MODULE_IDX,
|
||||
constant.WSPLISTENER_MODULE_IDX,
|
||||
constant.HTTP_LISTENER_MODULE_IDX,
|
||||
}
|
||||
|
||||
var app common.App
|
||||
var roomMgr common.RoomMgr
|
||||
@ -31,4 +38,46 @@ func GetApp() common.App {
|
||||
|
||||
func RegModule(idx int32, m q5.Module) {
|
||||
modules[idx] = m
|
||||
switch (idx) {
|
||||
case constant.APP_MODULE_IDX:
|
||||
{
|
||||
app = m.(common.App)
|
||||
}
|
||||
case constant.WSPLISTENER_MODULE_IDX:
|
||||
{
|
||||
wspListener = m.(common.WspListener)
|
||||
}
|
||||
case constant.HANDLER_MGR_MODULE_IDX:
|
||||
{
|
||||
//wspListener = m.(.common.H)
|
||||
}
|
||||
case constant.HTTP_LISTENER_MODULE_IDX:
|
||||
{
|
||||
//wspListener = m.(.common.H)
|
||||
}
|
||||
case constant.PLAYER_MGR_MODULE_IDX:
|
||||
{
|
||||
playerMgr = m.(common.PlayerMgr)
|
||||
}
|
||||
case constant.ROOMMGR_MODULE_IDX:
|
||||
{
|
||||
roomMgr = m.(common.RoomMgr)
|
||||
}
|
||||
default:
|
||||
{
|
||||
panic("unknow module")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func InitModules() {
|
||||
for _, val := range(initOrders) {
|
||||
modules[val].Init()
|
||||
}
|
||||
}
|
||||
|
||||
func UnInitModules() {
|
||||
for _, val := range(initOrders) {
|
||||
modules[val].UnInit()
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,14 @@
|
||||
package initialize
|
||||
|
||||
/*
|
||||
import (
|
||||
"f5"
|
||||
_ "main/room"
|
||||
_ "main/player"
|
||||
_ "main/listener"
|
||||
_ "main/app"
|
||||
|
||||
"main/global"
|
||||
"main/room"
|
||||
"main/player"
|
||||
"main/listener"
|
||||
"main/app"
|
||||
. "main/global"
|
||||
)
|
||||
*/
|
||||
|
||||
func Init() {
|
||||
//app.GetApp().SetCb(initApp, unInitApp)
|
||||
//f5.Run(app.GetApp())
|
||||
}
|
||||
|
||||
func initApp() {
|
||||
/*
|
||||
global.SetPlayerMgr(player.GetPlayerMgr())
|
||||
global.SetRoomMgr(room.GetRoomMgr())
|
||||
global.SetWspListener(listener.GetWspListener())
|
||||
|
||||
listener.GetHandlerMgr().Init()
|
||||
player.GetPlayerMgr().Init()
|
||||
room.GetRoomMgr().Init()
|
||||
listener.GetWspListener().Init()
|
||||
listener.GetHttpListener().Init()
|
||||
*/
|
||||
}
|
||||
|
||||
func unInitApp() {
|
||||
/*
|
||||
listener.GetHttpListener().UnInit()
|
||||
listener.GetWspListener().UnInit()
|
||||
room.GetRoomMgr().UnInit()
|
||||
player.GetPlayerMgr().UnInit()
|
||||
*/
|
||||
GetApp().Run(InitModules, UnInitModules)
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package room
|
||||
|
||||
var g = struct {
|
||||
roomMgr *roomMgr
|
||||
} {}
|
||||
import (
|
||||
"main/constant"
|
||||
"main/global"
|
||||
)
|
||||
|
||||
func GetRoomMgr() *roomMgr {
|
||||
if (g.roomMgr == nil) {
|
||||
g.roomMgr = new(roomMgr)
|
||||
}
|
||||
return g.roomMgr
|
||||
var _roomMgr = new(roomMgr)
|
||||
|
||||
func init() {
|
||||
global.RegModule(constant.ROOMMGR_MODULE_IDX, _roomMgr)
|
||||
}
|
||||
|
2
third_party/q5
vendored
2
third_party/q5
vendored
@ -1 +1 @@
|
||||
Subproject commit 9823133648feefa1692f7e451b94d2ae00184785
|
||||
Subproject commit ed967899c443330d8a83e121f28cf11768df6611
|
Loading…
x
Reference in New Issue
Block a user