pb

package
v0.0.0-...-2692626 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MutableCopy

func MutableCopy(src proto.Message, dst proto.Message) error

MutableCopy 深拷贝

Types

type Body

type Body struct {
	RawData []byte
}

type Handler

type Handler func(header IHeader, message proto.Message, obj interface{}) *liberror.Error

Handler 处理函数

type IBody

type IBody interface {
}

type IHeader

type IHeader interface {
	Marshal() []byte  // 将 成员变量 -> data 中
	Unmarshal([]byte) // 将 data 数据 -> 成员变量中
}

type IPacket

type IPacket interface {
	// Marshal 序列化
	//	返回:
	//		数据
	Marshal(unserializedPacket *UnserializedPacket) (data []byte, err error)
	// Unmarshal 反序列化
	//	参数:
	//		data:数据(包头+包体)
	//	返回:
	//		UnserializedPacket:未序列化的数据包
	Unmarshal(data []byte) (unserializedPacket *UnserializedPacket, err error)
}

IPacket 接口-数据包

type Message

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

Message contains options to configure a server instance. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.

func NewMessage

func NewMessage() *Message

NewMessage 创建 Message

func (*Message) GetName

func (p *Message) GetName() string

func (*Message) Handler

func (p *Message) Handler(header IHeader, message proto.Message, obj interface{}) *liberror.Error

Handler 处理

func (*Message) SetHandler

func (p *Message) SetHandler(handler Handler) *Message

func (*Message) SetNewPBMessage

func (p *Message) SetNewPBMessage(newPBMessage NewPBMessage) *Message

func (*Message) Unmarshal

func (p *Message) Unmarshal(data []byte) (message proto.Message, err error)

Unmarshal 反序列化

message: 反序列化 得到的 消息

type Mgr

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

Mgr 管理器

func (*Mgr) Find

func (p *Mgr) Find(messageID uint32) *Message

func (*Mgr) Init

func (p *Mgr) Init()

Init 初始化管理器

func (*Mgr) Register

func (p *Mgr) Register(messageID uint32, messageSlice ...*Message) error

Register 注册消息

func (*Mgr) Replace

func (p *Mgr) Replace(messageID uint32, messageEntity *Message) error

Replace 替换/覆盖(Override)

type NewPBMessage

type NewPBMessage func() proto.Message

NewPBMessage 创建新的 proto.Message

type UnserializedPacket

type UnserializedPacket struct {
	Header  IHeader       // 包头
	Message proto.Message // 数据
}

UnserializedPacket 未序列化的数据包

Jump to

Keyboard shortcuts

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