1
This commit is contained in:
parent
c2b32f4d1b
commit
7086631f1a
@ -20,9 +20,10 @@ func (this *app) GetPkgName() string {
|
|||||||
return "imserver"
|
return "imserver"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *app) SetCb(initCb func(), unInitCb func()) {
|
func (this *app) Run(initCb func(), unInitCb func()) {
|
||||||
this.initCb = initCb
|
this.initCb = initCb
|
||||||
this.unInitCb = unInitCb
|
this.unInitCb = unInitCb
|
||||||
|
f5.Run(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *app) Init() {
|
func (this *app) Init() {
|
||||||
|
@ -36,6 +36,6 @@ type HttpListener interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type App interface {
|
type App interface {
|
||||||
SetCb(func(), func())
|
Run(func(), func())
|
||||||
AddNetMsg(*f5.MsgHdr)
|
AddNetMsg(*f5.MsgHdr)
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,6 @@ const (
|
|||||||
WSPLISTENER_MODULE_IDX
|
WSPLISTENER_MODULE_IDX
|
||||||
HANDLER_MGR_MODULE_IDX
|
HANDLER_MGR_MODULE_IDX
|
||||||
HTTP_LISTENER_MODULE_IDX
|
HTTP_LISTENER_MODULE_IDX
|
||||||
|
PLAYER_MGR_MODULE_IDX
|
||||||
MAX_MODULE_IDX
|
MAX_MODULE_IDX
|
||||||
)
|
)
|
||||||
|
@ -7,6 +7,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var modules [constant.MAX_MODULE_IDX]q5.Module
|
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 app common.App
|
||||||
var roomMgr common.RoomMgr
|
var roomMgr common.RoomMgr
|
||||||
@ -31,4 +38,46 @@ func GetApp() common.App {
|
|||||||
|
|
||||||
func RegModule(idx int32, m q5.Module) {
|
func RegModule(idx int32, m q5.Module) {
|
||||||
modules[idx] = m
|
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
|
package initialize
|
||||||
|
|
||||||
/*
|
|
||||||
import (
|
import (
|
||||||
"f5"
|
_ "main/room"
|
||||||
|
_ "main/player"
|
||||||
|
_ "main/listener"
|
||||||
|
_ "main/app"
|
||||||
|
|
||||||
"main/global"
|
. "main/global"
|
||||||
"main/room"
|
|
||||||
"main/player"
|
|
||||||
"main/listener"
|
|
||||||
"main/app"
|
|
||||||
)
|
)
|
||||||
*/
|
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
//app.GetApp().SetCb(initApp, unInitApp)
|
GetApp().Run(InitModules, UnInitModules)
|
||||||
//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()
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package room
|
package room
|
||||||
|
|
||||||
var g = struct {
|
import (
|
||||||
roomMgr *roomMgr
|
"main/constant"
|
||||||
} {}
|
"main/global"
|
||||||
|
)
|
||||||
|
|
||||||
func GetRoomMgr() *roomMgr {
|
var _roomMgr = new(roomMgr)
|
||||||
if (g.roomMgr == nil) {
|
|
||||||
g.roomMgr = new(roomMgr)
|
func init() {
|
||||||
}
|
global.RegModule(constant.ROOMMGR_MODULE_IDX, _roomMgr)
|
||||||
return g.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