package main

import (
	_ "games.yol.com/win88"
	_ "mongo.games.com/game/mgrsrv/api"
	_ "mongo.games.com/game/srvdata"
	"time"

	"mongo.games.com/game/common"
	"mongo.games.com/game/model"
	"mongo.games.com/game/srvdata"
	"mongo.games.com/goserver/core"
	"mongo.games.com/goserver/core/logger"
	"mongo.games.com/goserver/core/module"
)

func main() {
	core.RegisterConfigEncryptor(common.ConfigFE)
	defer core.ClosePackages()
	core.LoadPackages("config.json")

	model.InitGameParam()
	logger.Logger.Warnf("log data %v", srvdata.Config.RootPath)
	waiter := module.Start()
	waiter.Wait("main()")
}

func init() {
	//首先加载游戏配置
	core.RegisteHook(core.HOOK_BEFORE_START, func() error {
		model.StartupRPClient(common.CustomConfig.GetString("MgoRpcCliNet"), common.CustomConfig.GetString("MgoRpcCliAddr"), time.Duration(common.CustomConfig.GetInt("MgoRpcCliReconnInterV"))*time.Second)
		return nil
	})

	core.RegisteHook(core.HOOK_AFTER_STOP, func() error {
		model.ShutdownRPClient()
		return nil
	})
}
