Documentation ¶
Index ¶
- Constants
- Variables
- func ActionToBytes(action uint32) []byte
- func CreateAction(packetType PacketType, module uint8, action uint16) uint32
- func CreateHeader(data []byte, version, encodeType uint8, action uint32) []byte
- type Packet
- func (p *Packet) GetActionKey() uint32
- func (p *Packet) GetEncodeType() uint8
- func (p *Packet) GetLength() uint32
- func (p *Packet) GetModule() uint8
- func (p *Packet) GetPacketType() PacketType
- func (p *Packet) GetVersion() uint8
- func (p *Packet) ToByte() []byte
- func (p *Packet) ToData() *bytebuffer.ByteBuffer
- type PacketType
- type Pool
Constants ¶
View Source
const ( // 协议头长度 HeaderLength = 8 // 协议头标识 HeaderFlag = 0x7E // 最大内容程度,16MBB MaxPacketSize = 1 << 24 )
Variables ¶
View Source
var ( GetPacket = _pool.GetPacket PutPacket = _pool.PutPacket )
View Source
var ErrEncodeType = errors.New("wrong encode type")
View Source
var ErrHeaderFlag = errors.New("wrong header flag")
View Source
var ErrHeaderLength = errors.New("wrong header length")
View Source
var ErrMaxPacketSize = errors.New("max packet size")
Functions ¶
func ActionToBytes ¶
func CreateAction ¶
func CreateAction(packetType PacketType, module uint8, action uint16) uint32
Types ¶
type Packet ¶
5.6.7byte length: 24bit 消息长度
func NewPacketWithHeader ¶
func (*Packet) GetActionKey ¶
packetType: 2bit // 0x01: system, 0x02: service module: 6bit action: 16bit 合一起的值 协议头/2/3/4字节
func (*Packet) GetEncodeType ¶
func (*Packet) GetPacketType ¶
func (p *Packet) GetPacketType() PacketType
func (*Packet) GetVersion ¶
func (*Packet) ToData ¶
func (p *Packet) ToData() *bytebuffer.ByteBuffer
type PacketType ¶
type PacketType byte
const ( // 系统内置包,如Ping Pong SystemPacket PacketType = 0x01 // 服务类型包,如Login、Register ServicePacket PacketType = 0x02 )
Click to show internal directories.
Click to hide internal directories.