Help us shape the future of Go! Take the 2026 Go Developer Survey

handler

package
v1.12.11 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NameToId

func NameToId(name string) uint32

func Register0

func Register0[A any](f M0Func[A], flags ...uint32)

Register0 注册0参数函数

func Register1

func Register1[A any, R any](f M1Func[A, R], flags ...uint32)

Register1 注册1参数函数

func Register2

func Register2[A any, R any, U any](f M2Func[A, R, U], flags ...uint32)

Register2 注册2参数函数

Types

type HandlerMgr

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

func NewHandlerMgr

func NewHandlerMgr() *HandlerMgr

func (*HandlerMgr) Get

func (d *HandlerMgr) Get(head *packet.Head) IHandler

Get 获取handler 优先按名称查找,失败时回退到按数字 ID 查找(兼容跨服务路由时 ActorFuncName 残留的场景)

func (*HandlerMgr) GetByActorFunc

func (d *HandlerMgr) GetByActorFunc(id uint32) IHandler

GetById 通过ID获取handler

func (*HandlerMgr) GetByActorFuncName

func (d *HandlerMgr) GetByActorFuncName(name string) IHandler

GetByName 通过名称获取handler

func (*HandlerMgr) Register

func (d *HandlerMgr) Register(handler IHandler)

Register 注册handler

type IHandler

type IHandler interface {
	GetActorFuncName() string                // 获取处理函数名称
	GetActorFunc() uint32                    // 获取处理函数唯一ID
	GetMask() uint32                         // 获取屏蔽模式
	Call(any, define.IContext, ...any) error // 调用处理函数
}

func Get

func Get(head *packet.Head) IHandler

Get 获取处理函数

func GetByActorFunc

func GetByActorFunc(id uint32) IHandler

GetById 获取处理函数

func GetByActorFuncName

func GetByActorFuncName(name string) IHandler

GetByName 获取处理函数

type M0

type M0[A any] struct {
	// contains filtered or unexported fields
}

func NewM0

func NewM0[A any](f M0Func[A], flag uint32) *M0[A]

func (*M0[A]) Call

func (d *M0[A]) Call(a any, ctx define.IContext, args ...any) error

func (*M0[A]) GetActorFunc

func (d *M0[A]) GetActorFunc() uint32

func (*M0[A]) GetActorFuncName

func (d *M0[A]) GetActorFuncName() string

func (*M0[A]) GetMask

func (d *M0[A]) GetMask() uint32

type M0Func

type M0Func[A any] func(A, define.IContext) error // 处理函数0

type M1

type M1[A any, R any] struct {
	// contains filtered or unexported fields
}

func NewM1

func NewM1[A any, R any](f M1Func[A, R], flag uint32) *M1[A, R]

func (*M1[A, R]) Call

func (d *M1[A, R]) Call(a any, ctx define.IContext, args ...any) error

func (*M1[A, R]) GetActorFunc

func (d *M1[A, R]) GetActorFunc() uint32

func (*M1[A, R]) GetActorFuncName

func (d *M1[A, R]) GetActorFuncName() string

func (*M1[A, R]) GetMask

func (d *M1[A, R]) GetMask() uint32

type M1Func

type M1Func[A any, R any] func(A, define.IContext, R) error // 处理函数1

type M2

type M2[A any, R any, U any] struct {
	// contains filtered or unexported fields
}

func NewM2

func NewM2[A any, R any, U any](f M2Func[A, R, U], flag uint32) *M2[A, R, U]

func (*M2[A, R, U]) Call

func (d *M2[A, R, U]) Call(a any, ctx define.IContext, args ...any) error

func (*M2[A, R, U]) GetActorFunc

func (d *M2[A, R, U]) GetActorFunc() uint32

func (*M2[A, R, U]) GetActorFuncName

func (d *M2[A, R, U]) GetActorFuncName() string

func (*M2[A, R, U]) GetMask

func (d *M2[A, R, U]) GetMask() uint32

type M2Func

type M2Func[A any, R any, U any] func(A, define.IContext, R, U) error // 处理函数2

Jump to

Keyboard shortcuts

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