protocol

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2020 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

func NewHandlers

func NewHandlers(handler interface{}) []*Handler

func (*Handler) Call

func (h *Handler) Call(gmt *agent.Meta, c2s proto.Message, s2c proto.Message) (err error)

func (*Handler) Cmd

func (h *Handler) Cmd() uint32

func (*Handler) Name

func (h *Handler) Name() string

type Protocol

type Protocol struct {
	Cmd     uint32
	Client  reflect.Type
	Server  reflect.Type
	Comment string
}

游戏协议结构

func NewProtocol

func NewProtocol(cmd uint32, client, server interface{}, comment string) *Protocol

func (*Protocol) NewClient

func (r *Protocol) NewClient() proto.Message

func (*Protocol) NewServer

func (r *Protocol) NewServer() proto.Message

type Router

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

游戏协议路由

func NewRouter

func NewRouter() *Router

func (*Router) AddCmd

func (r *Router) AddCmd(cmd uint32, client, server interface{}, comment string)

func (*Router) Call

func (r *Router) Call(gmt *agent.Meta, cmd uint32, req []byte) (rsp []byte, err error)

调用

func (*Router) Cmd

func (r *Router) Cmd(cmd uint32) *Protocol

func (*Router) Handler

func (r *Router) Handler(handles ...interface{})

注册

func (*Router) NewClientProto

func (r *Router) NewClientProto(cmd uint32) proto.Message

func (*Router) NewServerProto

func (r *Router) NewServerProto(cmd uint32) proto.Message

func (*Router) ParseClientProto

func (r *Router) ParseClientProto(cmd uint32, req []byte) (proto.Message, error)

func (*Router) Routes

func (r *Router) Routes() map[uint32]*Handler

注册

Jump to

Keyboard shortcuts

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