packet

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SeqSize     = 4
	MsgIDSize   = 4
	MsgTypeSize = 1
	ErrcodeSize = 4
	PktSizeSize = 4
)

Variables

View Source
var (
	PingPacket = &Packet{
		msgType: MsgPing,
	}
	PongPacket = &Packet{
		msgType: MsgPong,
	}
)

Functions

func PutPacket

func PutPacket(pk *Packet)

Types

type MessageType

type MessageType = byte
const (
	MsgReq MessageType = 1 + iota // need reply
	MsgReply
	MsgPush // no reply
	MsgErr  // error reply
	MsgPing
	MsgPong
)

type Packet

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

func GetPacket

func GetPacket() *Packet

func (*Packet) GetErrcode

func (p *Packet) GetErrcode() int32

func (*Packet) GetMsgID

func (p *Packet) GetMsgID() int32

func (*Packet) GetMsgType

func (p *Packet) GetMsgType() MessageType

func (*Packet) GetPayload

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

func (*Packet) GetSeq

func (p *Packet) GetSeq() uint32

func (*Packet) Reset

func (p *Packet) Reset()

func (*Packet) SetPayload

func (p *Packet) SetPayload(payload []byte)

Jump to

Keyboard shortcuts

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