packet

package
v0.0.0-...-aed9a31 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Unlicense Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMessageIsNil  = errors.New("the message is nil")
	ErrRouteOverflow = errors.New("the message route overflow")
)

Functions

func NewPacker

func NewPacker() inet.Packer

func Pack

func Pack(mid int32, data []byte) ([]byte, error)

Pack 打包消息

func Unpack

func Unpack(buf []byte) (mid int32, data []byte, err error)

Unpack 解包消息

Types

type IMessage

type IMessage interface {
	GetMsgId() int32
	GetBody() []byte
	GetBodyLen() int
}

type Message

type Message struct {
	Route  int32  // 路由ID
	Buffer []byte // 消息内容
}

func (*Message) GetBody

func (mp *Message) GetBody() []byte

func (*Message) GetBodyLen

func (mp *Message) GetBodyLen() int

func (*Message) GetMsgId

func (mp *Message) GetMsgId() int32

type Packet

type Packet struct{}

func (*Packet) Pack

func (p *Packet) Pack(mid int32, data []byte) ([]byte, error)

Pack 打包消息

func (*Packet) Unpack

func (p *Packet) Unpack(buf []byte) (mid int32, data []byte, err error)

Unpack 解包消息

Jump to

Keyboard shortcuts

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