1024programmer Java Goleaf game open source framework, from entry to burial (1)

Goleaf game open source framework, from entry to burial (1)

leaf download address: https://github.com/name5566/leaf

leafserver download address: https://codeload.github.com/name5566/leafserver

Catalog description

leaf/chanrpc provides a channel-based RPC mechanism for communication between game server modules

 leaf/db database related, currently supports MongoDB

 leaf/gate gateway module, responsible for game client access

 leaf/go is used to create goroutines that can be managed by Leaf

 leaf/log log related

 Leaf/network is related to the network. It uses the TCP protocol and can customize the message format. Currently, Leaf provides message formats based on protobuf and JSON.

 leaf/recordfile is used to manage game data

 leaf/timer timer related

 leaf/util auxiliary library

Configuration file method

In leafserver/bin/conf/server.json, leaf can support both tcp and websocket, of course you need to be able to configure it

 "LogLevel": "debug", log printing level
 "LogPath": "", log printing path
 "TCPAddr": "", tcp parameter setting
 "MaxConnNum": 20000 Maximum number of connections

Package startup service

leafserver needs to include leaf and websocket. For the address of the package, see the import path. Thanks to the person who led the way in writing the reference. Mom no longer has to worry that I can’t find the address to download the package

After running and saving without errors, the go build command generates one. exe executable file, copy it to the leafserver/bin directory, run it, the following prompt will appear, everything is ok,

Interpret the main of this official website

First look at main.go, en…. Simple and clear, not bb

import lconf "github.com/name5566/leaf/conf"
 func main() {
 //-----------Load bin/conf/server/server.json into leafconf
 lconf.LogLevel = conf.Server.LogLevel
 lconf.LogPath = conf.Server.LogPath
 lconf.LogFlag = conf.LogFlag
 lconf.COnsolePort= conf.Server.ConsolePort
 lconf.ProfilePath = conf.Server.ProfilePath

 //Run the module

Here are three modules: game, gate, and login registered in order. Each module needs to implement the interface:

type Module interface {
 Run(closeSig chan bool)

Another thing to note is that pasting someone else’s paragraph

Unlike some web servers, most of the data running by Leaf is in the memory. Although the Mongo module is provided, the data for real-time interaction is generally stored in the memory. Mongo is just for persisting some user data. This is very different from some stateless web servers that rely on databases for data interaction.

How to use this server, let’s listen to the explanation next time

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/763142

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us


Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top