pb_packet

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DataLen      = 2
	MessageIDLen = 1

	MinPacketLen = DataLen + MessageIDLen
	MaxPacketLen = (2 << 8) * DataLen
	MaxMessageID = (2 << 8) * MessageIDLen
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MsgProtocol

type MsgProtocol struct {
}

MsgProtocol is used to read message according to protocol

func (*MsgProtocol) ReadPacket

func (p *MsgProtocol) ReadPacket(r io.Reader) (network.Packet, error)

type Packet

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

Packet is the message sent by the server to the client

func NewPacket

func NewPacket(id uint8, msg interface{}) *Packet

NewPacket creates a new packet

func (*Packet) GetData

func (p *Packet) GetData() []byte

func (*Packet) GetMessageID

func (p *Packet) GetMessageID() uint8

func (*Packet) Serialize

func (p *Packet) Serialize() []byte

func (*Packet) UnmarshalPB

func (p *Packet) UnmarshalPB(msg proto.Message) error

Jump to

Keyboard shortcuts

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