Go leaf游戏开源框架,从入门到入土(一)
leaf下载地址:https://github.com/name5566/leaf
leafserver下载地址:https://codeload.github.com/name5566/leafserver
目录说明
import lconf "github.com/name5566/leaf/conf"
func main() {//-----------将bin/conf/server/server.json 加载到 leafconf中lconf.LogLevel = conf.Server.LogLevellconf.LogPath = conf.Server.LogPathlconf.LogFlag = conf.LogFlaglconf.ConsolePort = conf.Server.ConsolePortlconf.ProfilePath = conf.Server.ProfilePath//将模块运行起来leaf.Run(game.Module,gate.Module,login.Module,)
}
这里按顺序注册了 game、gate、login 三个模块。每个模块都需要实现接口:
type Module interface {OnInit()OnDestroy()Run(closeSig chan bool)
}
还有需要注意的是,粘贴别人的一段话
与一些Web服务器不同,Leaf运行的数据绝大部分都在内存里面,虽然提供了Mongo模块,但是做实时交互的数据一般是保存在内存中的。Mongo只是为了持久化一些用户数据。这与有些无状态,靠数据库做数据交互的Web服务器有很大不同。
那怎样使用这个服务器那,且听下回分解
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
