gogs

package module
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 26 Imported by: 5

README

gogs: Golang Game Server Framework

version GitHub Workflow Status codecov goversion license GitHub issues GitHub last commit GitHub top language

gogs is an simple, fast and lightweight game server framewrok written in golang. It is designed to be easy to use and easy to extend. It will generate logic code from protobuf files, and you can use it to develop your game server. It is also a good choice for you to learn golang. It support websocket and webrtc datachannel.


TODO
  • Support metrics
  • Support generate Unity C# SDK
  • Support JS SDK
  • Support Remote call
  • Support tracing
  • Support gogs generate docker file
  • Support gogs generate k8s yaml
  • Add more examples
  • Add more tests
  • Add more documentation
  • Test coverage reaches 80%

Getting Started

Prerequisites
Init your project

install the gogs

go install github.com/metagogs/gogs/tools/gogs@v0.0.9

init project

mkdir yourgame
cd yourgame
gogs init -p yourgame

edit your proto, add the game message, then generate the code

gogs go -f data.proto

run your game server

go mod tidy
go run main.go
Generated Project
internal/
    logic/
        baseworld/
            bind_user_logic.go
    server/
        server.go
    svc/
        service_context.go
model/
    data.ep.go
    data.pb.go
config.yaml     
data.proto      
main.go

Contributing

Running the gogs tests
make test

This command will run both unit and e2e tests.

License

Apache License Version 2.0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version string

Functions

func NewBuilder

func NewBuilder(config *config.Config) *builder

Types

type App

type App struct {
	*zap.Logger

	MessageServer *message.MessageServer // 消息管理

	LatencyServer *latency.LatencyServer // 延时服务管理
	GroupServer   *group.GroupServer     // 组管理

	Config *config.Config
	// contains filtered or unexported fields
}

func NewApp

func NewApp(config *config.Config) *App

func (*App) AddAcceptor

func (app *App) AddAcceptor(acceptor acceptor.Acceptor)

func (*App) GetAcceptors

func (app *App) GetAcceptors() []acceptor.Acceptor

func (*App) GetSessionPool

func (app *App) GetSessionPool() session.SessionPool

func (*App) Helper

func (app *App) Helper() *appHelper

func (*App) RegisterComponent

func (app *App) RegisterComponent(sd component.ComponentDesc, ss interface{})

func (*App) RegisterWebHandler

func (app *App) RegisterWebHandler(port int, f func(gin *gin.Engine))

func (*App) SetAgentFactory

func (app *App) SetAgentFactory(factory *agent.AgentFacotry)

func (*App) Shutdown

func (app *App) Shutdown()

func (*App) Start

func (app *App) Start()

func (*App) UseDefaultEncodeJSON

func (app *App) UseDefaultEncodeJSON()

func (*App) UseDefaultEncodeJSONWithHeader

func (app *App) UseDefaultEncodeJSONWithHeader()

func (*App) UseDefaultEncodeProto

func (app *App) UseDefaultEncodeProto()

type NetworkComponent

type NetworkComponent struct {
	// contains filtered or unexported fields
}

func NewNetworkComponent

func NewNetworkComponent(app *App) *NetworkComponent

func (*NetworkComponent) Pong

func (s *NetworkComponent) Pong(ctx context.Context, sess *session.Session, pong *proto.Pong)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL