game

package
v0.0.0-...-d853fe5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitConfig

func InitConfig()

Types

type Config

type Config struct {
	Env                    string `yaml:"env"`                      //  env: product/test/dev
	RunEnv                 string `yaml:"run_env"`                  //  run_env: host,k8s
	LogFile                string `yaml:"log_file"`                 //	log_file: gate.log
	LogLevel               string `yaml:"log_level"`                //	log_level: debug
	NetTimeout             string `yaml:"net_timeout"`              //	net_timeout: 1000
	SendSize               string `yaml:"send_size"`                //	send_size:
	ReadSize               string `yaml:"read_size"`                //	read_size:
	RsaKey                 string `yaml:"rsa_key"`                  //	rsa_key: rsa.key
	RsaCertificate         string `yaml:"rsa_certificate"`          //	rsa_certificate: rsa.crt
	CompressConnection     string `yaml:"compress_connection"`      //	compress_connection: false
	EncryptConnection      string `yaml:"encrypt_connection"`       //	encrypt_connection: false
	HeartbeatCheckInterval string `yaml:"heartbeat_check_interval"` //	heartbeat_check_interval: 0

	LocalProxy bool         `yaml:"local_proxy"` //proxy 和 game绑定在一起部署
	Proxy      conf.NetConf `yaml:"proxy"`
}
var CFG Config

type Game

type Game struct {
	entity.Entity

	// 可以重写这个接口,自己规划EntityID中的ID部分,比如用来承载UID等
	IDGenerator

	EntityMgr *entity.EntityManager

	// todo
	DB db.IDatabase
	// contains filtered or unexported fields
}

func NewGame

func NewGame(opts ...Option) *Game

func (*Game) HandleClose

func (g *Game) HandleClose(cn *nets.Conn)

func (*Game) HandleEOF

func (g *Game) HandleEOF(cn *nets.Conn)

func (*Game) HandleFail

func (g *Game) HandleFail(cn *nets.Conn)

func (*Game) HandleTimeOut

func (g *Game) HandleTimeOut(cn *nets.Conn)

func (*Game) NewEntityID

func (g *Game) NewEntityID() entity.EntityID

NewEntityID 如果没有特殊规划,可以使用这个生成entity id

func (*Game) RegisterServiceToProxy

func (g *Game) RegisterServiceToProxy(svcName string) error

func (*Game) Serve

func (g *Game) Serve()

type IDGenerator

type IDGenerator interface {
	GenID() entity.ID
}

type Option

type Option func(*Game)

func WithIDGenerator

func WithIDGenerator(gener IDGenerator) Option

Jump to

Keyboard shortcuts

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